Bug 12787 - Use a larger scaled glyph cache for CJK languages
Summary: Use a larger scaled glyph cache for CJK languages
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.5.1
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL: http://www.gnome.org/~federico/news-2...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-12 01:19 UTC by Federico Mena-Quintero
Modified: 2008-10-12 01:28 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Federico Mena-Quintero 2007-10-12 01:19:59 UTC
Profiles indicate that for CJK languages, glyphs get scaled too frequently because the default cache is too small:

http://www.gnome.org/~federico/news-2007-10.html#pango-cjk-1

cairo-scaled-font.c has this:
#define MAX_GLYPHS_CACHED_PER_FONT 256

and it includes a comment that it would be better to have a cache shared across all fonts, with a random replacement policy.

Simply increasing this value to 2048 gives very good results; with the pango-profile benchmark, scaling glyphs went from using about 60% of the time to only using about 13%.

This bug is a reminder that a cache shared across shared fonts is desirable.
Comment 1 Behdad Esfahbod 2007-10-16 10:38:16 UTC
Federico, I expect that the profile is a bit artificial as no normal application needs so many unique characters at once...

I'm fine with increasing current 256 to 512 or 1024 though.  But lemme blog about how to make it not increase process size first...

(may want to do something similar in pango caches too.)
Comment 2 Behdad Esfahbod 2007-10-16 11:06:49 UTC
Here's the secret:

http://mces.blogspot.com/2007/10/episode-vi-return-of-federico.html

Basically, if you make cairo-xlib-surface.c release glyph surfaces after uploading them to the X server, without hurting the case of image surface using them, you can increase the cache size without much affecting process size.

A good enough scheme would be to release the surface if xlib-surface caused it to be created.  But we don't have the means to find that out right now I guess.
Comment 3 Federico Mena-Quintero 2007-10-19 09:18:22 UTC
(In reply to comment #1)
> Federico, I expect that the profile is a bit artificial as no normal
> application needs so many unique characters at once...

View a CJK page in Firefox (say, the daily news).  You'll get plenty of unique glyphs :)

We could certainly patch Pango to build histogram of this for profiling purposes.
Comment 4 Behdad Esfahbod 2007-10-19 09:54:23 UTC
Can you give the enlarged cache size another try with my xlib patch?
Comment 5 Chris Wilson 2008-10-12 01:28:11 UTC
Moved to a "global glyph cache" TODO.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.