[Fontconfig] Excessive short-lived allocations during FcFontSet
behdad at behdad.org
Wed Apr 23 12:51:21 PDT 2008
Thanks Chris! Finally...
I suggest keeping the FcCharSetOperate name and call the new one
FcCharSetOperateInPlace(). Other than that, looks good to me. Keith,
this single change is worth a release on itself.
PS. Chris, given that you have some familiarity with the fontconfig
code now, if you feel like hacking, there's some useful and easy bugs to
close for 2.6:
On Wed, 2008-04-23 at 09:38 +0100, Chris Wilson wrote:
> As everyone who has profiled the memory allocation behaviour of a Pango
> using app knows (hi Behdad!) FcCharSetFindLeafCreate dominates the
> profile during initialisation. And then every time Pango has to load a
> new fontset.
> For a very simple GTK+ application just opening a window:
> Allocator nAllocs nBytes
> FcCharSetFindLeafCreate 62886 2012352
> FcCharSetPutLeaf 9361 11441108
> For gedit loading a UTF-8 demo:
> FcCharSetFindLeafCreate 124872 3995904
> FcCharSetPutLeaf 18656 22372816
> AIUI, the current behaviour of FcSortWalk() is to create a new FcCharSet
> on each iteration that is the union of the previous iteration with the
> next FcCharSet in the font set. This causes the existing FcCharSet to be
> duplicated in its entirety and then allocates fresh leaves for the new
> FcCharSet. In essence the number of allocations is quadratic wrt the
> number of fonts required.
> By introducing a new FcCharSet operator to merge a new FcCharSet into an
> existing FcCharset, we can reduce the allocations to cover the leaves in
> all the fonts in the set and no more.
> For gedit loading the UTF-8 demo, after the patch:
> FcCharSetFindLeafCreate 1940 62080
> FcCharSetPutLeaf 281 190336
> Please review, thanks.
> Chris Wilson
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
More information about the Fontconfig