[Fontconfig] Application startup performance
patrick.haller at haller-consult.de
Fri Jan 8 18:24:25 PST 2016
Profiling application startup performance, I noticed that libfontconfig
accounted for a significant portion of the startup time, approx. 30% for
a rather simple application like gedit.
My font directories, especially /usr/share/fonts/100dpi and
/usr/share/fonts/75dpi contain each 1900 files after a default gentoo
installation of X.org, residing on local storage.
I found two rather small optimizations to improve the startup time:
- assuming that readdir() will never return duplicate filenames within
the very same directory. Hence FcStrSetAdd() can spare the duplicate
check, which currently runs FcStrCmp() along a growing linear list of
filenames. In fact, I have not found any duplicate string being entered
to a FcStrSet at all for my system configuration.
- _FcStrSetAppend() to not reallocate and memcmp element by element, but
doing so for e. g. 64 elements at a time.
I've verified startup time using
- time gedit (average over 9 runs)
- callgrind and cachegrind
- skip duplicate check in FcStrSetAppend for values originating from
- grow FcStrSet in 64-element bulks for local FcStrSets (FcConfig layout
Starting gedit is measured to
user[s] 0,806 0,579
sys[s] 0,062 0,062
Total Instr Fetch Cost: 1.658.683.750 895.069.820
Cachegrind D Refs: 513.917.619 312.000.436
Cachegrind Dl Misses: 8.605.632 4.954.639
The patch is attached. Comments and questions are welcome.
Patrick Haller (patrick.haller at haller-consult.de)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6379 bytes
Desc: not available
More information about the Fontconfig