<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 Steffi,<div><br><div><div>On 24 Sep 2014, at 02:12, Preibisch, Stephan <<a href="mailto:preibischs@janelia.hhmi.org">preibischs@janelia.hhmi.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<div 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></blockquote><div><br></div><div>Yes, absolutely.</div><div><br></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<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></blockquote><div><br></div><div>I did not do any larger tests yet.</div><div><br></div><div>Whether it would be |accessibles| x |types| for imglib depends on how it is used.</div><div>Lets assume that you have a function</div><div><font face="Menlo"> <T extends Type<T>> T getMax( Cursor<T> c, T type )</font></div><div><div>Then it depends on how you annotate it. For</div><div><div><font face="Menlo"> @Instantiate <T extends Type<T>> T getMax( @ByTypeOf Cursor<T> c, T type )</font></div><div><div>it would be instantiate it for ArrayCursor and ArrayLocalizingCursor, but ArrayCursor<IntType> and ArrayCursor<FloatType> would share the same instance.</div><div>For</div><div><div><font face="Menlo"> @Instantiate <T extends Type<T>> T getMax( Cursor<T> c, </font><span style="font-family: Menlo;">@ByTypeOf</span><span style="font-family: Menlo;"> </span><span style="font-family: Menlo;">T type )</span></div><div><div>it would be instantiated for IntType and FloatType, but ArrayCursor<IntType> and ArrayLocalizingCursor<IntType> would share the same instance.</div><div>For</div><div><div><font face="Menlo"> @Instantiate <T extends Type<T>> T getMax( </font><span style="font-family: Menlo;">@ByTypeOf</span><span style="font-family: Menlo;"> </span><font face="Menlo">Cursor<T> c, </font><span style="font-family: Menlo;">@ByTypeOf</span><span style="font-family: Menlo;"> </span><span style="font-family: Menlo;">T type )</span></div><div>you would have the full |cursor| x |type| space.</div><div><br></div><div>I don’t see this becoming a big problem at the moment.</div><div>We should anyway not indiscriminately apply it everywhere, only where we can really show a performance increase.</div><div><br></div><div>I see it as more of an issue if we add more of these instantiation idioms, for example for specializing classes. Then the number of instances might multiply through chains of such instantiations. Imagine the above with Cursor classes being generated depending on Type and number of dimensions. And that with Types being generated depending on the underlying Access.</div><div><br></div><div>The nice thing is that you only pay for what you actually use.</div><div>In any case, it is easy to cap the number of instances that are generated at a fixed number, and use the same instance for every newly occurring type after that.</div></div></div><div><font face="Menlo"><br></font></div></div></div></div></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<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></blockquote><div><br></div><div>Cool, thanks!</div><div>Tobias</div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div><br>
</div>
<div>Cheers,</div>
<div>Steffi<br>
<div apple-content-edited="true">
<div style="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>
</div><div><br class="webkit-block-placeholder"></div>
-- <br>
-- <br>
Please avoid top-posting, and please make sure to reply-to-all!<br>
<br>
Mailing list web interface: <a href="http://groups.google.com/group/fiji-devel">http://groups.google.com/group/fiji-devel</a><br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "Fiji-devel" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:fiji-devel+unsubscribe@googlegroups.com">fiji-devel+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br>
</blockquote></div><br></div></body></html>