<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
Hi Tobi,
<div><br>
</div>
<div>this does look pretty impressive indeed. As it is modified on runtime, it should even work with new Types and Accessibles that are not part of ImgLib2 but some external program that is based on ImgLib2 and adds for example its own types, or?</div>
<div><br>
</div>
<div>Did you test if this scales well with larger number of instances? For ImgLib2 it would be something like |accessibles| x |types|, right? In many cases it would not use a lot of the possibilities, but for something like KNIME or ImageJ2 this might actually
happen.</div>
<div><br>
</div>
<div>Again, looks awesome! And if it turns out to be working in all cases, I agree, this could be a huge game changer.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Steffi<br>
<div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="orphans: 2; widows: 2;">---</div>
<div style="orphans: 2; widows: 2;"><br>
</div>
<div style="orphans: 2; widows: 2;">Dr. Stephan Preibisch</div>
<div style="orphans: 2; widows: 2;">HFSP Fellow</div>
<div style="orphans: 2; widows: 2;">Robert H. Singer / Eugene Myers lab</div>
<div style="orphans: 2; widows: 2;"><br>
</div>
<div style="orphans: 2; widows: 2;">Albert Einstein College of Medicine / HHMI Janelia Farm / MPI-CBG</div>
<div style="orphans: 2; widows: 2;"><br>
</div>
<div style="orphans: 2; widows: 2;">email: <a href="mailto:stephan.preibisch@einstein.yu.edu">stephan.preibisch@einstein.yu.edu</a> / <a href="mailto:preibischs@janelia.hhmi.org">preibischs@janelia.hhmi.org</a> / <a href="mailto:preibisch@mpi-cbg.de">preibisch@mpi-cbg.de</a></div>
<div style="orphans: 2; widows: 2;">web: <a href="http://fly.mpi-cbg.de/preibisch">http://www.preibisch.net/</a></div>
</div>
</div>
<br>
<div>
<div>On Sep 23, 2014, at 19:02 , Tobias Pietzsch <<a href="mailto:pietzsch@mpi-cbg.de">pietzsch@mpi-cbg.de</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">Hi guys,<br>
<br>
As a weekend project I have started to look into bytecode modification using the wonderful ASM library (<a href="http://asm.ow2.org">http://asm.ow2.org</a>).<br>
I have cleaned up what I have played with and put it on github <a href="https://github.com/tpietzsch/neon">
https://github.com/tpietzsch/neon</a>.<br>
<br>
It tackles a long-standing imglib obstacle, namely megamorphic call-sites in certain methods, where the JIT fails to recognise that the runtime target of the polymorphic changes between calls to a method but doesn’t change in the hot inner loop of the method
during a single call. I have been talking about ideas to address this for quite some time, most recently here
<a href="https://github.com/imglib/imglib/issues/71#issuecomment-51227237">https://github.com/imglib/imglib/issues/71#issuecomment-51227237</a>. Now I went ahead and actually tried to do something about it.<br>
<br>
I have applied it to an example in imglib, which is described below. But for anyone not familiar with this particular issue (which is everyone except Christian probably) there<br>
is an illustrative example with explanations in the README on github <a href="https://github.com/tpietzsch/neon/blob/master/README.md">
https://github.com/tpietzsch/neon/blob/master/README.md</a>.<br>
This does not involve imglib at all and is a clear illustration of the problem (and my solution).<br>
<br>
I’m quite happy with how it turned out so far. It certainly has to be applied with care, but I think this can be potentially huge for imglib2. It might open up new possibilities that we have shied away from because of performance reasons, such as internal iteration
for IterableIntervals.<br>
<br>
Curtis, Johannes and Christian, I would also be interested what you think of this as a potential tool for imagej-ops.<br>
I think it is orthogonal to what you do with compile-time code generation currently and therefore might complement it nicely.<br>
<br>
I hope you have a look and tell me what you think.<br>
I would be especially interested in whether you can think of optimization idioms besides the @Instantiate @ByTypeOf that is implemented right now.<br>
It would be cool if we discuss this in the upcoming imglib hackathon.<br>
<br>
Okay, everybody except Christian might as well stop reading now.<br>
<br>
all the best,<br>
Tobias<br>
<br>
<br>
<br>
<br>
<br>
PS: the imglib stuff...<br>
<br>
For the imglib issue <a href="https://github.com/imglib/imglib/issues/71">https://github.com/imglib/imglib/issues/71</a>, we played with ways of iterating pixels which can be optimized for certain subintervals of larger images.<br>
The optimizations work out nicely when done on their own, but everything really breaks down when a single method is used with differnent Cursor incarnations.<br>
This is actually already a potential problem in standard imglib, when Cursors from different Img types are uses in a single method. But adding the new optimized versions<br>
only made it more probable that the problem actually occurs.<br>
<br>
Here is numbers from a recent test, at a stage where 4 different kinds of cursors are in play:<br>
<br>
normal cursor | array img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>566<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>371<span class="Apple-tab-span" style="white-space:pre"> </span>| 195ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 34.4% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
localizing cursor | array img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>907<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>584<span class="Apple-tab-span" style="white-space:pre"> </span>| 323ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 35.6% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
normal cursor | planar img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>562<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>373<span class="Apple-tab-span" style="white-space:pre"> </span>| 189ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 33.6% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
localizing cursor | planar img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>928<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>611<span class="Apple-tab-span" style="white-space:pre"> </span>| 317ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 34.1% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
<br>
With the neon java agent this improves to:<br>
<br>
normal cursor | array img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>153<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>8<span class="Apple-tab-span" style="white-space:pre"> </span>| 145ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 94.7% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
localizing cursor | array img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>235<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>200<span class="Apple-tab-span" style="white-space:pre"> </span>| 35ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 14.8% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
normal cursor | planar img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>128<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>8<span class="Apple-tab-span" style="white-space:pre"> </span>| 120ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 93.7% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
localizing cursor | planar img<br>
walk through a subinterval<br>
<span class="Apple-tab-span" style="white-space:pre"></span>| Unoptimized <span class="Apple-tab-span" style="white-space:pre">
</span>| Optimized <span class="Apple-tab-span" style="white-space:pre"></span>| Speedup Time
<span class="Apple-tab-span" style="white-space:pre"></span>| Speedup % <span class="Apple-tab-span" style="white-space:pre">
</span>|<br>
Best<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>217<span class="Apple-tab-span" style="white-space:pre"> </span>|<span class="Apple-tab-span" style="white-space:pre">
</span>208<span class="Apple-tab-span" style="white-space:pre"> </span>| 9ms <span class="Apple-tab-span" style="white-space:pre">
</span>| 4.1% <span class="Apple-tab-span" style="white-space:pre"> </span>|<br>
<br>
<br>
A speedup of factor ~4 to ~40 can be observed.<br>
These two runs were made with exactly the same code, but for the second one, the program was run with the option<br>
java -javaagent:/path/to/neon-1.0.0-SNAPSHOT.jar …<br>
<br>
I just pushed the example to <a href="https://github.com/imglib/imglib/commit/a9b70d923e9a84c4055acae96f71d05ca4a26344">
https://github.com/imglib/imglib/commit/a9b70d923e9a84c4055acae96f71d05ca4a26344</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</body>
</html>