[cairo] Optimizing the fetching calls
sandmann at daimi.au.dk
Fri Apr 25 23:26:47 PDT 2008
Antoine Azar <cairo at antoineazar.com> writes:
> While profiling a test app I did with Cairo (mostly scaled up/down and
> rotated blitting), I noticed a LOT of time is spent fetching and storing
> pixels in Pixman. I had a look and implemented a small optimization that
> substantially reduces the number of fetching calls needed. This optimization
> works well especially in the cases of scaled up blitting and bilinear
> filtering, as we'll be often requesting the same pixels many times in a row.
> There's no point in fetching them again.
> In my test app, blitting an image 11 times ranging linearly between scales
> of 1.0 to 3.0 (while rotating 10 degrees each time), this patch goes from
> 18.6 million calls of fbfetch down to 10 million.
> I'm attaching here my patch, along with some benchmark results. The
> performance gains go up to about 3X.
> I'm still looking into further optimizing fetching/storing calls.
I think it may be worthwhile trying to get the fetch code inline
again. Ie., along the lines of:
It's untested and the same things needs to be done in more places, but
the idea should be clear.
The idea of reusing the last sample if the coordinates are the same is
not a bad one, but I'd like to first see what, if any, effect inlining
Also, if you could attach your test application that would be helpful.
More information about the cairo