[Fontconfig] Application startup performance

Akira TAGOH akira at tagoh.org
Thu Jan 14 22:27:25 PST 2016


On Thu, Jan 14, 2016 at 11:15 PM, Nick Alcock <nick.alcock at oracle.com> wrote:
> Digging into this some more, the underlying problem is that
> FcDirCacheMapFd() unconditionally calls FcCacheDirsValid(), which more
> or less always calls FcDirScanOnly(), which does a readdir() on the
> directory (already pointless) and an FcFileIsDir() on every file in
> it... which devolves to an FcStat() even though this also is pointless
> because we just readdir()ed it, which got the d_type... and then we
> threw it away only to have to re-stat() it again.

As I mentioned in other mail, it was needed to avoid the races. to get
rid of it completely, the logic of the cache updates may needs to be
changed because keeping the directory information into the memory a
long time causes that issue easily when recursively traversing
directories.

> A repair of *that* (incidentally dropping a qsort() -- in a path as hot
> as this! -- whose declared intent is only 'to make things prettier' and
> whose other declared intent, to prevent Heisenbugs, is probably
> relatively minor and can be reintroduced under a debug flag later on --
> I don't know if it has any actual effect on semantics but I doubt it),
> though incomplete and ugly, helps a lot. my set of fonts is restricted
> right now because I'm sick of waiting for half a minute for programs to
> start, but even with this, we see the time required for fontconfig font
> scanning dropping from 2.865s to 0.05s.

Roughly looking at the log in git, it used to be needed when the cache
was stored into the huge cache file. indeed it may be not needed any
more.

> This patch will probably need changing in small ways if we care about
> any systems on which dentry.d_type does not exist (probably we do: this
> is just a proof of concept):

Thanks. modified a bit for platforms which doesn't have d_type in
dirent and the invalid cache issue when a directory contains a symlink
to dir. it looks good so far. I'll test more and push into git then.

-- 
Akira TAGOH


More information about the Fontconfig mailing list