[rrd-developers] [rrd] Re: pango / fontconfig / cairo performance with rrdtool
behdad at behdad.org
Mon Sep 1 18:17:45 CEST 2008
Tobias Oetiker wrote:
> Yesterday Behdad Esfahbod wrote:
>> Tobias Oetiker wrote:
>>>> Hi Tobias,
>>>> The part creating the layout looks good. Any *interesting* thing will be
>>>> hidden in other parts of the code, namely the code calling this function. In
>>>> general I'm quite surprised that you are hitting the load_fontset() path all
>>>> the time as the fontsets should be cached and simply reused. One way to debug
>>>> it is to run with FC_DEBUG=1 and look for all different Sort Patterns passed
>>>> to fontconfig and see how they differ (I'm guessing minor difference in the size).
>>> I just finished modifying the code, so that I am keeping multiple
>>> sets of PangoFontDescriptions for each combination of font and
>>> size. I then pass the FontDescription into the text function. This
>>> magically resolved the problem ... now the load_fontset gets only
>>> called 3 times or so ...
>>> Does this match expectations ?
>> Not really. As I said, most probably you have been creating
>> slightly-different font descriptions. You can run the old code and print out
>> the font descriptions to see what has been causing it. In general you should
>> not need to cache much to make Pango behave. Just use the default font map
>> (which you are) and it should work reasonably.
> I am using the same font name across the board in 4 different sizes.
> DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,Courier 7
> DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,Courier 8
> DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,Courier 9
> DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,Courier 5.5
> Is there a way to figure what font pango picked based on my
> description and then tell it to use this one again ?
> Could it be that when I ask for font
> "ABC,CCD 9"
> that pango finds
> "CCD 8.99999"
> and then when I ask again for
> "ABC,CCD 9"
> it goes looking again ?
> Could it be that I am doing something that makes pango forget about
> the fonts (flush its cache).
No, unless you:
- Use a different fontmap each time (that is, you use
- Call pango_fc_font_map_clear_cache()
- Use more than 64 different font descriptions
none of which you seem to be doing.
> How should I be structuring my program for optimal results.
> Have a separate layout for each font I am going to use and then
> switch layout according to the font ?
Fontsets are cached on the fontmap. Recreating layout and/or font
descriptions should not matter as long as you use the exact same font description.
> As I said, I have shuffled my code around and suddenly the time
> for generating a second graph has gone down dramatically. I just
> don't know exactly why.
Can't tell without closely inspecting your code. But I already suggested how
to debug it further using FC_DEBUG.
> old code:
> shuffled code with separate PangoFontDescription structures for
> each font/size which I then apply to the layout as required:
> rrd 1.2 code with libart/freetype:
More information about the rrd-developers