[cairo] Optimizing the fetching calls

Soeren Sandmann sandmann at daimi.au.dk
Wed Apr 30 18:11:09 PDT 2008


> > I think it may be worthwhile trying to get the fetch code 
> > inline again. Ie., along the lines of:
> > 
> >    http://www.daimi.au.dk/~sandmann/faster-transform.patch
> > 
> > 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 has.
> I tested your proposed modification, I'm getting around a 15% speed boost.
> It's a good idea and I could work on applying it in all the other places and
> building a patch out of it.

> In any case I think it's independent of my previous optimization, so if you
> don't have any objections to it, please go ahead and push it. We can add
> your optimization on top of it later.

They are not really independent, because your patch gets its speedups
from eliminating fetch calls, which are currently expensive. But
inlining fetch calls will make them cheaper, which will affect how much
performance improvement we will see from your patch.

This is important because your patch is not free in all cases. When
scaling up, the same source pixel is fetched many times in a row, but
when scaling down, we don't look at the same pixel more than once, so
there could be some overhead there.

On the other hand, inlining should make all cases cheaper, so we need
to do that first and then see (a) how much of an improvement the pixel
caching is when scaling up, and (b) what effect, if any, it has on

> For testing my optimization, I used a slightly modified version of the paint
> perf test (forcing the extend and filtering modes). I also built a small pet
> application to check the visual results of the optim, and running Vtune on
> it. The code is following (some unused variables, you can ignore
> them).

Thanks. We should probably add it to the cairo performance and test
suites. With Fred's work on better quality scaling, it should become
useful for testing that as well.


More information about the cairo mailing list