[cairo] [PATCH] scaled-font: optimize cairo_scaled_font_text_to_glyphs()
dmitri.vorobiev at movial.com
Wed Jun 9 11:43:40 PDT 2010
On Wed, Jun 9, 2010 at 9:38 PM, Behdad Esfahbod <behdad at behdad.org> wrote:
> On 06/09/2010 12:20 PM, Dmitri Vorobiev wrote:
>> + for (i = 0; i < ARRAY_LENGTH (glyph_lut_unicode); i++)
>> + glyph_lut_unicode[i] = ~0U;
> Or you can initialize all to 0, and initialize  to non-zero.
I tried this. There was no measurable speed gain.
>> + if (num_chars > 1)
> I didn't notice that the glyph_lut was added to cairo. I would have sugested
> making the backend accesses and caches faster instead of adding yet another
> cache on top... After all, this cache is cleaned up across function calls!
> Initializing 256 cache entries is a lot of overhead when in GUI's, the average
> string lengths passed to cairo are really short, but longer than 1.
> And I suggest making the cache smaller. Much smaller. According to
> Wikipedia, the top 12 most frequent English letters comprise more than 80% of
> the the total usage . And I suggest extending the fast path to all short
> strings (not only length 1). So, what I suggest:
> - Either remove the lut cache or reduce it to 32 or 64 entries.
> - Bypass the cache codepath for strings shorter than 16.
OK, I will try these two tomorrow and then report what kind of speed
gain we can get.
> - As a special-case optimization in the non-cached case, if the current
> letter is the same as the previous letter, skip the lookup and reuse the
> result from last letter.
OK, thanks for the idea.
More information about the cairo