Last idea: I will enhance Andrea's mapBench benchmark to have statistics per threads: number of loops, avg, min, max, stddev; <br><br>I guess that the total bench time is not so representative as the thread pool can distribute the work load differently at each test => statistics will help to have better timing / comparison between bench runs.<br>
<br>Regards,<br>Laurent<br><br><div class="gmail_quote">2013/4/11 Laurent Bourgès <span dir="ltr"><<a href="mailto:bourges.laurent@gmail.com" target="_blank">bourges.laurent@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Jim and Sergey,<br><br>1/ Here are few benchmarks (based on mapBench again) running several modified versions of AAShapePipe:<br><a href="http://jmmc.fr/%7Ebourgesl/share/AAShapePipe/mapBench/" target="_blank">http://jmmc.fr/~bourgesl/share/AAShapePipe/mapBench/</a><br>
- ref: <br>1 threads and 20 loops per thread, time: 3742 ms<br>2 threads and 20 loops per thread, time: 4756 ms<br>4 threads and 20 loops per thread, time: 8528 ms<br><br>1 threads and 20 loops per thread, time: 56264 ms<br>
2 threads and 20 loops per thread, time: 75566 ms<br>4 threads and 20 loops per thread, time: 141546 ms<br><br>- int4:<br>1 threads and 20 loops per thread, time: 3653 ms<br>2 threads and 20 loops per thread, time: 4684 ms<br>
4 threads and 20 loops per thread, time: 8291 ms<br><br>1 threads and 20 loops per thread, time: 55950 ms<br>2 threads and 20 loops per thread, time: 74796 ms<br>4 threads and 20 loops per thread, time: 139924 ms<br><br>
- byte[]:<br>
1 threads and 20 loops per thread, time: 3795 ms<br>2 threads and 20 loops per thread, time: 4605 ms<br>4 threads and 20 loops per thread, time: 8246 ms<br><br>1 threads and 20 loops per thread, time: 54961 ms<br>2 threads and 20 loops per thread, time: 72768 ms<br>
4 threads and 20 loops per thread, time: 139430 ms<br><br>- int4 / byte[] / rectangle cached in TileState:<br>1 threads and 20 loops per thread, time: 3610 ms<br>2 threads and 20 loops per thread, time: 4481 ms<br>4 threads and 20 loops per thread, time: 8225 ms<br>
<br>1 threads and 20 loops per thread, time: 54651 ms<br>2 threads and 20 loops per thread, time: 74516 ms<br>4 threads and 20 loops per thread, time: 140153 ms<br><br>So you may be right, results are varying depending on the optimizations (int4, byte or all) !<br>
Maybe I should test different versions on optimized pisces renderer ...<br><br>Here is an updated patch:<br><a href="http://jmmc.fr/%7Ebourgesl/share/AAShapePipe/webrev-2/" target="_blank">http://jmmc.fr/~bourgesl/share/AAShapePipe/webrev-2/</a><br>
<br><br>2/ Thanks for your comments: actually a refactoring is possible to use a (shared) TileState instance replacing int[] bbox, rectangle bbox):<br>- RenderingEngine.AATileGenerator getAATileGenerator(... int[] abox)<br>
<br>it is very interesting here to propose an extensible tile state: maybe created by the renderer engine to cache other data ?<br><br>- Rectangle and Rectangle2D are only used as the shape s and device rectangle given to CompositePipe.startSequence():<br>
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle dev, int[] abox);<br><br>Changing this interface may become difficult:<br>AlphaColorPipe.java: <br> 41: public Object startSequence(SunGraphics2D sg, Shape s, Rectangle dev,<br>
OK, [s, dev, abox] unused<br><br>AlphaPaintPipe.java<br> 81: public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,<br>create a paint context:<br> PaintContext paintContext =<br> sg.paint.createContext(sg.getDeviceColorModel(),<br>
devR,<br> s.getBounds2D(),<br> sg.cloneTransform(),<br> sg.getRenderingHints());<br>
<br>GeneralCompositePipe.java:<br> 62: public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,<br>abox unused and create a paint context:<br> PaintContext paintContext =<br> sg.paint.createContext(model, devR, s.getBounds2D(),<br>
sg.cloneTransform(),<br> hints);<br><br>SpanClipRenderer.java<br> 68: public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,<br>Forward to another composite pipe<br>
return new SCRcontext(ri, outpipe.startSequence(sg, s, devR, abox));<br><br>It could be possible to use TileState into PaintContext interface / fix implementations but it may become a tricky change (API change).<br><br>What do you think ?<span class="HOEnZb"><font color="#888888"><br>
<br>Laurent</font></span><div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">2013/4/11 Jim Graham <span dir="ltr"><<a href="mailto:james.graham@oracle.com" target="_blank">james.graham@oracle.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I'm pretty familiar with all of this code and there aren't any places that save the tile array that I remember. The embedded code that Pisces was taken from had some caching of alpha arrays, but we didn't use or keep that when we converted it for use in the JDK...<br>
<br>
It occurs to me that since you are collecting the various pieces of information into an object to store in the thread local storage, perhaps we should convert to a paradigm where an entire Tile Generation sequence uses that object "TileState?" as its main way to communicate info around the various stages. Thus, you don't really need an int[4] to store the 4 parameters, they could be stored directly in the TileState object. This would require more sweeping changes to the pipeline, but it might make the code a bit more readable (and make the hits to convert over more moot as they would be improving readability and give more focus to the relationships between all of the various bits of data). Then it simply becomes a matter of managing the lifetime and allocation of the TileState objects which is a minor update to the newly refactored code.<br>
<br>
...jim<br>
<br>
On 4/10/13 3:59 PM, Sergey Bylokhov wrote:<div><div><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On 4/10/13 11:46 PM, Laurent Bourgčs wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I see that some methods which take it as argument doesn't use them. And<br>
most of the time we pass AATileGenerator and abox[] to the same<br>
methods, so<br>
it could be merged?<br>
<br>
</blockquote>
For now I did not want to modify the AAShapePipe signatures: abox[] is<br>
filled by AATileGenerator implementations (ductus, pisces, others) in<br>
order<br>
to have the shape bounds and render only tiles covering this area.<br>
</blockquote>
You still have to check all the places, where these objects are filled<br>
and used, and refactoring is a good start, no?<br>
Otherwise, how can you prove that these arrays are used as you would<br>
expect, These arrays could be stored like the cache or re-used for other<br>
purpose(if someone don't want to create new arrays).<br>
Probably it will be good to split all your changes / to a few CR.<br>
- cleanup<br>
- Some small changes which gave us most speedup<br>
- all other things.<br>
??<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Also I suggest to use jmh for java micrbenchmarks.<br>
<a href="http://openjdk.java.net/**projects/code-tools/jmh" target="_blank">http://openjdk.java.net/**<u></u>projects/code-tools/jmh</a><<a href="http://openjdk.java.net/projects/code-tools/jmh" target="_blank">http:/<u></u>/openjdk.java.net/projects/<u></u>code-tools/jmh</a>><br>
<br>
So your test will be:<br>
<a href="http://cr.openjdk.java.net/%7E**serb/AAShapePipeBenchmark.java" target="_blank">http://cr.openjdk.java.net/~**<u></u>serb/AAShapePipeBenchmark.java</a><u></u><<a href="http://cr.openjdk.java.net/%7Eserb/AAShapePipeBenchmark.java" target="_blank">http://cr.openjdk.java.net/%<u></u>7Eserb/AAShapePipeBenchmark.<u></u>java</a>><br>
<br>
<br>
</blockquote>
Thanks,<br>
I will try it asap<br>
<br>
Laurent<br>
<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
--<br>
Best regards, Sergey.<br>
<br>
<br>
</blockquote></blockquote>
<br>
<br>
</blockquote>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>