It's flying - if done right!

It's great to see the progress fontconfig does performancewise after such a long time without much progress. And it's great
that Dirk and me are referred to as "perf guys" in the fontconfig changelog now :)

One thing we learned while profiling fontconfig: most algorithms in there are (expensively) linear to the number of fonts, but there are even some more costly than that. So if you've been proud so far on your font collection, rethink your position: Make yourself aware that every font you have on your system, a KDE application spends roughly 100.000 (pentium) instructions on trying to find out if that is the best font. So if you have 1000 fonts on your system that you don't use in any application, that are 100 million instructions wasted.

Now the problem is that KDE doesn't need one font, but about five (monospace, sans serif fonts in different sizes). And as QFont is per process, every KDE/Qt application does this calculation from scratch. It very much depends on your setup of course, but let's assume we do this for 10 applications in KDE startup. So doing 50 font matches (way too few, but I'm just trying to make a point): this makes 5 Billion instructions wasted on KDE startup. Now divide this 5 by number of Ghz you have to see how many seconds you waste. So go - deinstall that fonts! 15 fonts ought to be enough for everyone :)


Can't the result of the font search be cached in fontconfig?

If I understand the problem correctly, each app finds the fonts that best match the font description on startup. So it gives a string to fontconfig and fontconfig gives back a font. With a small hashtable, such a search could be sped up. There would be a mechanism to clear the cache if the font directories change.

I'm no fontconfig expert, but just wondering where the problem is at the moment.

By jvdoever at Wed, 11/30/2005 - 13:09

(SUSE-9.1, 9.2, 9.3 as well as 10.0)

By Kurt Pf. at Wed, 11/30/2005 - 14:20

What if I don't remove the fonts but instead drop a into my .fonts.conf? I guess it should speed things up. As I have few fonts I can't really test but it should work...

By jayavarman at Wed, 11/30/2005 - 17:47

Your suggestion sounds similar to:
"If your old shoes become too small for your feet, cut off your fingers"

Aside from the valid observation of the problem, your post (suggestion) is coo-coo. (or, maybe a cruel joke?)

By suslikreal at Thu, 12/01/2005 - 18:23

The 15 fonts are of course a joke. My point is this: fontconfig 2.3 takes 300M instructions for a fc-match 'sans serif' - fontconfig 2.3.93 (not yet released :) takes 20M instructions. There were only factors reworked, but this will only work if people won't keep adding fonts to their system. And I'm talking about stupid fonts. If you have 1000 fonts, there will be 800 ugly in there - period.

By Stephan Kulow at Fri, 12/02/2005 - 12:08

Happy to hear that one of the "old beasts" of linux is being improved. Thanks!!!!

By Dario Massarin at Fri, 12/02/2005 - 11:28