Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.1.0 Beta 1, 5.1.0
-
None
-
Linux
-
dbe5306c2c4f5017827efb42aae69bdf8573674e
Description
We have seen by profiling a few months ago that iterating all the fonts is a big part of the startup time of any Qt application on Linux. I tried measuring by taking timestamps at the beginning and end of this function. Best case is about 300ms on a fast quad-core i7 with warm cache (run the same application several times). Worst case was 9 seconds on my Atom-based machine without having Qt cached, and doing an rsync in the background; but on that machine the best case even with warm cache and a non-debug build is 1.5 seconds. It seems like too much work is being done in this function, especially considering that fontconfig does too much XML parsing in order to fulfill the requests. The normal use case was supposed to be that when a user requests a font with a specific set of characteristics, you use fontconfig right then to find the best matching font. What Qt does instead is iterate all the fonts at startup and cache a lot of information about them. But it's probably worthwhile to have a little delay when choosing a font to get faster startup of the application. We also need a complete font list for the sake of font dialogs with conventional design; but maybe it could either be done on-demand or done by a background thread after the application is already running. Maybe we could also find a way to share the cached info between all Qt applications which are in memory at the same time.