[cairo] Overhead reduction

Jonathan Morton jonathan.morton at movial.com
Wed May 20 00:37:19 PDT 2009


> > > Other than that, an image pool is a good idea, and it would make sense
> > > to add synchronization primitives to pixman, similar to what is in
> > > cairo-mutex-*.h already. If we can track down the contributors to that
> > > file and get them to agree to relicensing to MIT, the code could be
> > > reused directly.
> > 
> > Shall I leave you to that part?  I can probably fix up the patch to use
> > the primitives once the licensing is sorted out.
> 
> It will be a while before I have time to look into this. I don't think
> it's particularly difficult - it should be a matter of running git
> blame on the files in question, then mailing people and asking if they
> are okay with a relicensing.
> 
> And also, of course, how the cairo developers in general feel about
> moving the thread synchronization primitives to pixman.

As it happens, I've written a custom framework to do *just* the
object-pool stuff portably.  It falls back to a trivial implementation
(just calling malloc and free) if it doesn't have the right atomic
operations to use, but aims to be fast in the common case where there is
little or no contention.

Apparently recent Linux kernels have an ABI interface that implements
basic atomic primitives for userspace's benefit.  That should simplify
providing them for most CPUs on one OS, though arguably other OSes may
need even more help with avoiding malloc's lack of speed.

Implementations for ARM, PPC[64] and x86[_64] should not be very
difficult to provide for most OS/compiler platforms.  When I've got the
ARM one working, I'll post a patch.  If the licensing gets sorted out,
that would probably be a good source for the remaining implementations.

> > Perhaps using a fixed allocation on the stack would be appropriate for
> > the common case(s) which use very low numbers, and falling back to
> > malloc for the general case.
> 
> Right, this is how we'd usually do it.

I've already implemented this; patch will come later.

-- 
------
From: Jonathan Morton
      jonathan.morton at movial.com




More information about the cairo mailing list