[cairo] Cairo and layered application

Behdad Esfahbod behdad at behdad.org
Mon Apr 9 10:28:41 PDT 2007


On Tue, 2007-03-06 at 17:16 -0500, Behdad Esfahbod wrote:
> On Tue, 2007-03-06 at 14:43 -0600, Boris Zbarsky wrote:
> > Behdad Esfahbod wrote:
> > >> Are you generally interested in data of this sort?  If there's something I can 
> > >> do to help improve cairo performance, I'd love to help.
> > > 
> > > Definitely.  Pass 'em on.  Specifically, I'm really interested in a call
> > > graph to malloc.  There's a lot we can do to drop those.
> > 
> > I'll try to get together a more exhaustive list, but in the meantime 
> > https://bugzilla.mozilla.org/show_bug.cgi?id=368018 is a decent example 
> > (16% of total pageload time is under malloc/free, most of it called from 
> > cairo).  Most of the other profiles I've seen look much like this, so it 
> > may be worth addressing this one and then reprofiling.
> >
> > I don't have a good way to generate pictorial call graphs, but as far as 
> > cairo calls to malloc in that testcase go (note that some of the 
> > callstacks might have stack frames skipped due to the profiler being 
> > used...):
> 
> Thanks.  The list really helps.  Fortunately all look very easy to
> optimize as I expected.  I just need a test case that gives
> malloc/realloc numbers so I can measure my progress.
> 
> One way would be to write a small .so that overrides malloc/realloc, and
> run perf suite against it.  If we were using glib, such stats were
> free...  Anyway, anyone taking this?

Ok, I did this myself.  I'll polish the result just a bit and post it
soon.

I fixed a lot of malloc uses, Chris Wilson did a couple, and Mathias
Hasselmann took the biggest of them that required quite a few changes.
Anyway, it's all pushed now except for one small patch I have waiting
for cworth to show up and review it.

I used the following script as benchmark:

../libtool --mode=execute /bin/true ./cairo-perf &&
CAIRO_TEST_TARGET=image
LD_PRELOAD="../test/libbacktracesymbols.so ../test/.libs/malloc-wrapper.so" .libs/lt-cairo-perf -i 1

Tail of before:

   10672  27,343,136       10672  27,343,136           0           0    _cairo_image_surface_composite_trapezoids
   10700     385,200       10700     385,200           0           0    FbPixelsCreateForData
   19068   4,132,896       19068   4,132,896           0           0    _cairo_bo_event_queue_init
   19068  22,730,928       19068  22,730,928           0           0    _cairo_bentley_ottmann_tessellate_polygon
   19068  33,063,168       19068  33,063,168           0           0    _cairo_bo_event_queue_init
   22492     180,832       22492     180,832           0           0    _cairo_surface_fill_region
   24308  76,068,168       24308  76,068,168           0           0    FbPixelsCreate
   24836   1,887,536       24836   1,887,536           0           0    _cairo_path_op_buf_create
   24848  13,020,352       24848  13,020,352           0           0    _cairo_path_arg_buf_create
   27016   6,159,648       27016   6,159,648           0           0    _cairo_image_surface_create_for_pixman_image
   29432     235,456       29432     235,456           0           0    _cairo_freelist_alloc
   34999   1,399,960       34999   1,399,960           0           0    _cairo_pixman_format_create_masks
   35008   4,060,928       35008   4,060,928           0           0    pixman_image_createForPixels
   35052  31,133,184           0           0       35052  31,133,184    _cairo_polygon_grow_by
   36964   4,731,392       36964   4,731,392           0           0    _cairo_pattern_create_solid
   40044   4,805,280       40044   4,805,280           0           0    cairo_pattern_create_radial
   50988 160,140,160           0           0       50988 160,140,160    _cairo_traps_grow_by
   54416  14,094,336           0           0       54416  14,094,336    _cairo_spline_grow_by
   81555   1,518,716       81555   1,518,716           0           0    alloc_node_for_level
  403368   4,840,416      403368   4,840,416           0           0    _cairo_pixman_region_create_simple
 1043842 422,531,916      902166 216,436,080      141676 206,095,836    (total)

After:

   10672  27,343,136       10672  27,343,136           0           0    _cairo_image_surface_composite_trapezoids()
   10700     385,200       10700     385,200           0           0    FbPixelsCreateForData()
   12480   3,358,720       11840   3,031,040         640     327,680    _cairo_spline_grow()
   17884  25,270,272       11304   8,681,472        6580  16,588,800    _cairo_polygon_grow()
   19068  22,730,928       19068  22,730,928           0           0    _cairo_bentley_ottmann_tessellate_polygon()
   24308  76,044,328       24308  76,044,328           0           0    FbPixelsCreate()
   27016   6,159,648       27016   6,159,648           0           0    _cairo_image_surface_create_for_pixman_image()
   28412 154,158,080       19492  24,949,760        8920 129,208,320    _cairo_traps_grow()
   29432     235,456       29432     235,456           0           0    _cairo_freelist_alloc()
   34999   1,399,960       34999   1,399,960           0           0    _cairo_pixman_format_create_masks()
   35008   4,901,120       35008   4,901,120           0           0    pixman_image_createForPixels()
   38136  37,196,064       38136  37,196,064           0           0    _cairo_bo_event_queue_init()
   40044   5,926,512       40044   5,926,512           0           0    cairo_pattern_create_radial()
   59117   1,289,740       59117   1,289,740           0           0    alloc_node_for_level()
  418421 377,834,509      401245 230,986,005       17176 146,848,504    (total)


Waiting for numbers from firefox, etc. :)

Cheers,

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list