summaryrefslogtreecommitdiff
path: root/src/cairo-scaled-font-private.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-03-16 19:31:38 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-03-16 20:51:50 +0000
commit9c80392ac415e7f07c71261d280ac4376d3c8471 (patch)
tree06e215c968816e5bb18c5400b5b895572e6f8c5e /src/cairo-scaled-font-private.h
parent121d4bb656755b7ca89065bf87e3e4e47c49c89d (diff)
[scaled-font] Lean and mean global glyph cache.
Jeff Muizelaar pointed out that the severe overallocation implicit in the current version of the glyph cache is obnoxious and prevents him from accepting the trunk into Mozilla. Jeff captured a trace of scaled font and glyph usage during a tp run and presented his analysis in http://lists.cairographics.org/archives/cairo/2009-March/016706.html Using that data, the design was changed to allocate pages of glyphs from a capped global pool but with per-font hash tables. This should allow the glyph cache to have tight memory bounds with fair allocation according to usage. Note that both the old design and the 1.8 glyph cache had essentially unbounded memory constraints, since each scaled font could cache up to 256 glyphs (1.8) or had a reserved page (old), with no limit on the number of active fonts. Currently the eviction policy is a simple random strategy, this gives a 'fair' allotment of the cache, but a LRU variant might perform better. On a sample run of firefox-3.0.7 perusing BBC news in 32 languages: 1.8: cache allocation 8190x, ~1.2 MiB; elapsed 88.2s old: cache allocation 771x, ~13.8 MiB; elapsed 81.7s lean: cache allocation 433x, ~1.8 MiB; elapsed 82.4s
Diffstat (limited to 'src/cairo-scaled-font-private.h')
-rw-r--r--src/cairo-scaled-font-private.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cairo-scaled-font-private.h b/src/cairo-scaled-font-private.h
index 89820c8f..f6c97488 100644
--- a/src/cairo-scaled-font-private.h
+++ b/src/cairo-scaled-font-private.h
@@ -106,8 +106,10 @@ struct _cairo_scaled_font {
/* The mutex protects modification to all subsequent fields. */
cairo_mutex_t mutex;
- int cache_frozen;
- cairo_scaled_glyph_page_t *mru_page;
+ cairo_hash_table_t *glyphs;
+ cairo_scaled_glyph_page_t *glyph_pages;
+ cairo_bool_t cache_frozen;
+ cairo_bool_t global_cache_frozen;
/*
* One surface backend may store data in each glyph.