[cairo] Profiling the slowness of xlib surface
vladimirv at gmail.com
Thu Apr 20 10:50:38 PDT 2006
You can see some more results with the cairo-bench program that I put
together, described in
There are some significant performance hits if you mix an image
surface with an xlib surface -- every time you draw to the xlib
surface, a temporary xlib surface is created and your image data gets
loaded into it. To compound this, I've heard that the X drivers often
allocate pixmaps in video memory; however nearly all of the current
Render calls are done in software through pixman on the server side,
so for every operation the data needs to be read back into main
memory, operated on, and then put back into video memory. This is
still the case even with two xlib surfaces. This basically means that
if you're running under X, in many cases you're better off doing as
much as you can in a local image surface, and only blitting the final
result to X.
On 4/20/06, Timothée Lecomte <timothee.lecomte at ens.fr> wrote:
> Hi all !
> For my gnuplot terminal based on Cairo, I use a temporary surface where I
> draw thousands of adjacent polygons with CAIRO_OPERATOR_SATURATE, and then
> I use the result as a source pattern to paint the main context.
> This process works quite well with both image surfaces, but is somewhat slow.
> But it is even worse if my main surface is a xlib surface, obtained by
> If I create my temporary surface with cairo_surface_create_similar(), I
> get the artifacts as reported in a previous post (thread "avoiding
> If I create the temporary surface with cairo_image_surface_create(), the
> output is correct.
> In both cases, the process is twice as slow compaired to the pure 'image
> surface' case.
> To track the slowness, I used sysprof to make a profile of the system calls.
> I use xorg 6.9, on a radeon, without the composite extension, and without
> Here are the results :
> * final and temporary image surface : 55% of the time spent on fbCopyAreammx
> * final xlib surface, temporary image surface : idem
> * final and temporary xlib surface : 46 % of the time spent on
> You can find the sysprof profiles here (you can open them in sysprof to
> see the tree of calls) :
> I don't know if something can be done, but it is somewhat discouraging to
> see that a pure image surface is faster than a xlib one. Does it mean that
> pixman uses X to render ?
> Can I do something to improve this situation ?
> Thanks for your help, and for the great work done on Cairo.
> Timothée Lecomte
> cairo mailing list
> cairo at cairographics.org
More information about the cairo