[cairo] [PATCH] scaled-font: optimize cairo_scaled_font_text_to_glyphs()

Jonathan Morton jonathan.morton at movial.com
Wed Jun 9 10:49:34 PDT 2010


On Wed, 2010-06-09 at 18:04 +0100, Chris Wilson wrote:
> On Wed,  9 Jun 2010 19:20:27 +0300, Dmitri Vorobiev <dmitri.vorobiev at movial.com> wrote:
> > This patch serves two purposes. First, it factors out the heavy part
> > of the cairo_scaled_font_text_to_glyphs() routine thus allowing GCC
> > to better optimize the cache cleanup loop. Keeping the look-up table
> > indices in a separate array speeds up array initialization even further.
> 
> The patch looks great, thanks! Care to share your benchmarks as well? A
> set of random ASCII text sounds like a reasonable addition to the
> microbenchmarks, but I wonder if you also have some profiles from a macro
> benchmark or application that shows the effect of this change? And it
> would be useful to include non-ASCII in that mix.

The effect on non-ASCII text should be in the same direction, the
magnitude depending on the extra overhead of decoding multibyte UTF-8
and identifying glyphs from non-Roman scripts.

The key thing this patch really works around is a major and persistent
failure in GCC's optimisers, which simply give up and leave a big mess
behind if a function crosses an arbitrary complexity threshold.  I saw
some pretty brain-dead repetition and missed opportunities in the ARM
code produced from the original.  I haven't yet closely examined the
PowerPC and AMD64 equivalents.

The single-character optimisation is just gravy that became obvious
while working on the refactoring.  The main things this skips are the
micro-cache initialisation and the glyph extents lookup.

I think I can try to run some of the standard cairo-perf tests against
the patch on an AMD64 machine I have at home.  They are a bit awkward to
run on our ARM device.

I've attached the benchmark source.  It was written to match the
behaviour of mx11mark under a specific test script, but using Cairo
instead of Xft.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bench.c
Type: text/x-csrc
Size: 2093 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100609/0b1335a1/attachment.c>


More information about the cairo mailing list