agg profiling

View: New views
9 Messages — Rating Filter:   Alert me  

agg profiling

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,

does anybody profiled his application? Currently I have few ideas how
to improve rendering speed in antigrain, but I will be interested
about comments if this makes sense. I profiled my library and I see
very big usage of trigonometric functions. These functions are
generally slow, so here is first idea how to improve code.

Here are my all ideas:
- Instead of sin() and cos() use sincos() (is this portable?) in code
that needs both (mainly agg::curves, agg::arc)
- Ideally rewrite sin and cos implementation using SSE2
- Ideally rewrite agg::conv_curves using SSE2

Anybody tried something like this ? Maybe the idea of fixed point
calculation of curves isn't also bad.

Also the effective sin and cos in SSE2 will probably degrade the
function to accept only float, so it's question if this can affect
rendering quality. The implementation is for example here:
http://gruntthepeon.free.fr/ssemath/.

I tried also to write multithreaded rendering using antigrain and I
have half success. I wrote own rasterizer (located here
http://code.google.com/p/fog/source/browse/trunk/Fog/thirdparty/agg-contrib/include/agg_rasterizer_scanline_aa_custom.h)
and with this rasterizer I can collect spans for each scanline
indenpendently. This makes some performance gain, but the path
rasterizing algorithm still runs in main thread and unfortunatelly
this consumes quite lot of CPU cycles.

Cheers
- Petr

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Jim Crafton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yeah I ran into something like this a while ago. I was using agg for
text rendering (only fixed width fonts) for a simple text editor and I
needed accurate text scaling. After I got everything to work
performance wasn't too hot, so I went and profiled things to narrow
down the bottlenecks. The final solution was to minimize the calls to
agg to *just* the exact bit of text that needed to be repaint, using
clipping, etc.  At one point I even emailed here to ask about some of
the MMX optimized code, and when I tried that, the speedup was there,
but not by very much.

> does anybody profiled his application? Currently I have few ideas how
> to improve rendering speed in antigrain, but I will be interested
> about comments if this makes sense. I profiled my library and I see
> very big usage of trigonometric functions. These functions are
> generally slow, so here is first idea how to improve code.


What about a lookup table for stuff like that? Somewhere I've heard of
people doing that, though I don't recall exactly how they set it up.

Cheers

Jim

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jim,

2009/5/16 Jim Crafton <jim.crafton@...>:
> Yeah I ran into something like this a while ago. I was using agg for
> text rendering (only fixed width fonts) for a simple text editor and I
> needed accurate text scaling. After I got everything to work
> performance wasn't too hot, so I went and profiled things to narrow
> down the bottlenecks. The final solution was to minimize the calls to
> agg to *just* the exact bit of text that needed to be repaint, using
> clipping, etc.  At one point I even emailed here to ask about some of
> the MMX optimized code, and when I tried that, the speedup was there,
> but not by very much.

Are you archived your MMX code or results? I'm interested with this.
My experience is that font rendering is best if you have large glyph
cache. Of cource this is not possible with transformations or it's
possible but very limited.

>> does anybody profiled his application? Currently I have few ideas how
>> to improve rendering speed in antigrain, but I will be interested
>> about comments if this makes sense. I profiled my library and I see
>> very big usage of trigonometric functions. These functions are
>> generally slow, so here is first idea how to improve code.
>
>
> What about a lookup table for stuff like that? Somewhere I've heard of
> people doing that, though I don't recall exactly how they set it up.

I don't like lookup tables :-)) Problem with lookup tables here is
that how big it must be to give good results? Also there will be big
memory read overhead, so I think that SSE2 code may perform better,
the question is, where to start?

Currently I'm very busy with my thesis, but I want to improve this
area, I really see here space for big improvements

- Petr

> Cheers
>
> Jim
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Christof Schardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> What about a lookup table for stuff like that? Somewhere I've heard of
>> people doing that, though I don't recall exactly how they set it up.

>I don't like lookup tables :-)) Problem with lookup tables here is
>that how big it must be to give good results?

And what's about lookup and interpolation?

Christof




------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Jim Crafton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Are you archived your MMX code or results?
No this was for work. However the MMX code was stuff that was posted
here - search through the list and I'm sure you'll find mention of it.
If you don't let me know and I can post back what I used if I can find
it.

> I'm interested with this.
> My experience is that font rendering is best if you have large glyph
> cache. Of cource this is not possible with transformations or it's
> possible but very limited.

I don't think I made much use of the cache. The text display scaled
with the size of the window (which is why GDI was completely useless
here) so this wasn't practical.

Cheers

Jim

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Christof,

intepolation is good idea, but do you think that this will be faster
and more accurate than the SSE2 source code I posted the link to? They
say that that function can calculate sincos() in ~20 cycles (4 in
parallel). I think that 20 cycles is very good, because normally this
takes up to ~150 to ~300 cycles on today CPUs. I need time to
experiment with this, currently I have deadline with my thesis, so not
too much time:)

2009/5/16 Christof Schardt <csnews@...>:

>>> What about a lookup table for stuff like that? Somewhere I've heard of
>>> people doing that, though I don't recall exactly how they set it up.
>
>>I don't like lookup tables :-)) Problem with lookup tables here is
>>that how big it must be to give good results?
>
> And what's about lookup and interpolation?
>
> Christof
>
>
>
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/5/17 Jim Crafton <jim.crafton@...>:
>> Are you archived your MMX code or results?
> No this was for work. However the MMX code was stuff that was posted
> here - search through the list and I'm sure you'll find mention of it.
> If you don't let me know and I can post back what I used if I can find
> it.

I will try to find it here, no problem:)

>> I'm interested with this.
>> My experience is that font rendering is best if you have large glyph
>> cache. Of cource this is not possible with transformations or it's
>> possible but very limited.
>
> I don't think I made much use of the cache. The text display scaled
> with the size of the window (which is why GDI was completely useless
> here) so this wasn't practical.
>
> Cheers
>
> Jim
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Christof Schardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> intepolation is good idea, but do you think that this will be faster
> and more accurate than the SSE2 source code I posted the link to?

Sorry, I've not any experience in this and so cannot compare.
It was just a thought.
However, two considerations:
- trigonometric functions in agg are not part of a numeric chain,
  where small errors could sum up and lead to unacceptable errors
  in the final results. It's only about visual representation and the
  the numerical precision requirements are loose, compared to
  scientific calculations
- if SSE2 is good in speeding up sinus and cosinus, it could
  also speed up the interpolation.

Best regards
Christof

P.S.:  I lurked around on your source-site, it is an impressive project,
I will stay tuned.





------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: agg profiling

by Petr Kobalíček :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/5/17 Christof Schardt <csnews@...>:

>> intepolation is good idea, but do you think that this will be faster
>> and more accurate than the SSE2 source code I posted the link to?
>
> Sorry, I've not any experience in this and so cannot compare.
> It was just a thought.
> However, two considerations:
> - trigonometric functions in agg are not part of a numeric chain,
>  where small errors could sum up and lead to unacceptable errors
>  in the final results. It's only about visual representation and the
>  the numerical precision requirements are loose, compared to
>  scientific calculations

This is good argument to try it :)

> - if SSE2 is good in speeding up sinus and cosinus, it could
>  also speed up the interpolation.

Definitely, SSE2 is actively used for that and I want to use it too.
In fact I used it to interpolate colors in gradient and the speedup is
significant.

> Best regards
> Christof
>
> P.S.:  I lurked around on your source-site, it is an impressive project,
> I will stay tuned.

Thanks. It's hard project, but I really want to finalize it;)

> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Vector-agg-general mailing list
> Vector-agg-general@...
> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general