[cairo] Profiling the slowness of xlib surface
Timothée Lecomte
timothee.lecomte at ens.fr
Thu Apr 20 11:11:47 PDT 2006
Thank you for your quick and clear answer.
This is a bad news for me ... Apart from the rendering artefacts in
CAIRO_OPERATOR_SATURATE with xlib surfaces, I was expecting it to be
faster.
Regarding my problem with seams, SATURATE is the best solution, but it
implies using a termporary surface. Other solutions are not satisying, as
far as I can tell (see previous threads about seams). So I guess I will to
forget about xlib surfaces.
Anyway is it normal to see so much time spent in these copy from main
memory and video memory ?
In my case, for each 'plot', I have :
* one pixmap for the main context
* two temporary surfaces created for two different sets of adjacent
polygons, each of them used once only
So, that make roughly a dozens of copy between main and video memory. Is
it normal for these calls to be so slow that the whole rendering (~1000
polygons to each temporary surfaces, several lines and text paths to the
main surface) takes hundreds of milliseconds ?
> 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.
Can this mean that each time I call cairo_fill(), for example, the server
copies the pixmap to main memory to render through pixman and then copies
it back to video memory ? In that case, that would make thousands of
copies back and forth for the whole rendering. I hope I am wrong !
Timothée
> You can see some more results with the cairo-bench program that I put
> together, described in
> http://lists.freedesktop.org/archives/cairo/2006-March/006547.html .
> 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.
>
> - Vlad
>
> 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
>> gtk_cairo_create(my_offscreen_pixmap).
>>
>> If I create my temporary surface with cairo_surface_create_similar(), I
>> get the artifacts as reported in a previous post (thread "avoiding
>> seams").
>> 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
>> EXA.
>>
>> 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
>> fbCompositeSrc_8888x8888mmx
>>
>> You can find the sysprof profiles here (you can open them in sysprof to
>> see the tree of calls) :
>> http://tipote.free.fr/profile_image_image
>> http://tipote.free.fr/profile_xlib_image
>> http://tipote.free.fr/profile_xlib_xlib
>>
>> 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.
>>
>> Regards,
>>
>> Timothée Lecomte
>>
>> _______________________________________________
>> cairo mailing list
>> cairo at cairographics.org
>> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
>>
>
More information about the cairo
mailing list