[cairo] Performance degradation of font cache in 1.11.3

Deokjin Kim deokjin81.kim at samsung.com
Fri Dec 30 01:53:15 PST 2011


Hello all,

When I measure elapased time of cairo using cairo-perf-trace, elapsed time of 1.10.2(release version) is shorter than that of 1.11.3(latest code). That is, performance of 1.10.2 is better than that of 1.11.3.
I think change of font cache is playing a role in causing this issue.

I found two root cause.
1. Use original_font_face instead of font_face when you create key of scaled font in cairo_scaled_font_create().
  This change degrades hit ratio of _cairo_hash_table_lookup().

 Below is related source code of 1.11.3.
 1028         _cairo_scaled_font_init_key (&key, original_font_face,
 1029                                      font_matrix, ctm, options);  // In 1.10.2, use font_face instead of original_font_face
 1030 
 1031         while ((scaled_font = _cairo_hash_table_lookup (font_map->hash_table,

2. Some change of hash table.
 - hash: Improve double hashing
 - hash: Compare hash values before calling keys_equal
 - hash: Improve handling of dead entries 
  I think purpose of above code change is very good, but actual result is not good.

As I know, 1 is more significant than 2. 
(Actually influence of 2 is slight.)

Please give me advice.
Thank you in advance.

BR,
Deokjin Kim


More information about the cairo mailing list