<div dir="ltr"><div>Thanks for clarification. No worries.<br><br></div>Rewriting the cache is an interesting challenge, but so far we don't have any volunteers.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 26, 2018 at 6:28 PM, Kurt Kartaltepe <span dir="ltr"><<a href="mailto:kkartaltepe@gmail.com" target="_blank">kkartaltepe@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have rebuilt 2.12.93 tonight and it appears I was mistaken. I had<br>
attempted to replace 2.12.6 in my build chain but that must have been<br>
reverted as 2.12.93 indeed provides ~100x improvement and builds the<br>
cache on my system in 600ms.<br>
<br>
I still hold this is not a "blanket you should improve it" post.<br>
Indeed a hashmap (or any mapping between patterns and files that<br>
allows rapid validation of non-dirty files) on disk that reuses the<br>
patterns for files that didnt change is indeed what I suggesting from<br>
the start. I don't see why this needs to be lock-free as the entire<br>
structure can be atomically updated using the same mechanisms already<br>
in use for the cache. I defer to your experience if this cache is<br>
contended enough to warrant such a structure.<br>
<br>
I understand this is would be a significant project which is why i<br>
brought it to the mailing list and now that font cache build times are<br>
in seconds for large font libraries it is indeed harder to justify.<br>
Thank you very much for your time and sorry this all started due to a<br>
mistake on my own part. (I hope I have not been using terms<br>
inappropriately. but I have been using font/file interchangeably and<br>
from your replies it appears this may have been a mistake).<br>
<span class="HOEnZb"><font color="#888888"><br>
--Kurt Kartaltepe<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mon, Feb 26, 2018 at 5:26 PM, Behdad Esfahbod <<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>> wrote:<br>
> On my laptop, warm fc-cache -f of over 2000 fonts takes 3.5s. So maybe worth<br>
> checking what's taking so much time on your setup.<br>
><br>
> Believe me, if we knew how to make it faster easily, we would have done. So,<br>
> any blanket "you should improve it" has no information content whatsoever.<br>
><br>
> Caching per font is not realistic.<br>
><br>
> The best I can think of, requires a complete rewrite of the caching, and<br>
> would use a single cache file that implements a lock-free hashmap on the<br>
> disk and reuses pattern for files that didn't change. But that's a very<br>
> significant project to undertake.<br>
><br>
> On Mon, Feb 26, 2018 at 3:38 AM, Kurt Kartaltepe <<a href="mailto:kkartaltepe@gmail.com">kkartaltepe@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Sorry It appears I have not been replying to the list.<br>
>><br>
>> I would like to add testing on 2.12.6 before the much improved<br>
>> performance changes was ~40s cache build times with significant disk<br>
>> I/O. So the newly improved scanning is much appreciated but doesn't<br>
>> solve all the issues with cache build times.<br>
>><br>
>> On Mon, Feb 26, 2018 at 5:29 AM, Kurt Kartaltepe <<a href="mailto:kkartaltepe@gmail.com">kkartaltepe@gmail.com</a>><br>
>> wrote:<br>
>> > 2.12.93 as released on<br>
>> > <a href="https://www.freedesktop.org/software/fontconfig/release/" rel="noreferrer" target="_blank">https://www.freedesktop.org/<wbr>software/fontconfig/release/</a><br>
>> ><br>
>> > On Mon, Feb 26, 2018 at 5:27 AM, Behdad Esfahbod <<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>><br>
>> > wrote:<br>
>> >> Just to make sure we are on the same page, which fontconfig version are<br>
>> >> you<br>
>> >> testing with?<br>
>> >><br>
>> >> On Mon, Feb 26, 2018 at 3:21 AM, Kurt Kartaltepe<br>
>> >> <<a href="mailto:kkartaltepe@gmail.com">kkartaltepe@gmail.com</a>><br>
>> >> wrote:<br>
>> >>><br>
>> >>> For clarification, I have tested with ONLY the ttf fonts on my system.<br>
>> >>> In this case the normal 18s cache build step takes 15s. This suggests<br>
>> >>> to me there is no significant difference between FON and TTF, as they<br>
>> >>> made up ~21% of my fonts and removing them resulted in a proportionate<br>
>> >>> savings. Sorry If my OP was misleadingly suggesting that FON files<br>
>> >>> were exceptionally slow, I only meant that they may not have received<br>
>> >>> the same improvement as TTF files which may just be my<br>
>> >>> misunderstanding of the changes you made and lack of testing.<br>
>> >>><br>
>> >>> I am concerned with why it seems acceptable to rebuild the entire<br>
>> >>> cache when only a tiny portion of it has actually changed. Users for<br>
>> >>> which rebuilding the cache is a significant event are those with large<br>
>> >>> font libraries. These users are are by their very nature more likely<br>
>> >>> to add or remove fonts from their library. It seems that this is the<br>
>> >>> worst possible case for the current caching strategy, and *this* seems<br>
>> >>> like an issue worth fixing.<br>
>> >>><br>
>> >>> In this case if checksuming files is slower than scanning them the<br>
>> >>> issue still stands. Why checksum files that haven't changed? Does<br>
>> >>> fontconfig not trust filesystem metadata? It would appear directory<br>
>> >>> change times are used in detecting when to rescan so why can this not<br>
>> >>> be extended to files instead of the expensive checksum?<br>
>> >>><br>
>> >>> FWIW an md5sum of my entire font library takes ~1s with hot caches<br>
>> >>> which I still find unacceptable as my library is possibly<br>
>> >>> significantly smaller and my system significantly more powerful than a<br>
>> >>> potential user's.<br>
>> >>><br>
>> >>> --Kurt Kartaltepe<br>
>> >>><br>
>> >>> On Sun, Feb 25, 2018 at 9:10 PM, Behdad Esfahbod <<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>><br>
>> >>> wrote:<br>
>> >>> > What's with fon files being slow? Please report *that* and let's fix<br>
>> >>> > it.<br>
>> >>> ><br>
>> >>> > We've made scanning, like, 100x faster already. 2007 stats are<br>
>> >>> > irrelevant.<br>
>> >>> > Checksuming files is slower than scanning them now.<br>
>> >>> ><br>
>> >>> > On Sun, Feb 25, 2018 at 8:08 AM, Kurt Kartaltepe<br>
>> >>> > <<a href="mailto:kkartaltepe@gmail.com">kkartaltepe@gmail.com</a>><br>
>> >>> > wrote:<br>
>> >>> >><br>
>> >>> >> While trying to move a project to the pango stack I noticed the<br>
>> >>> >> native<br>
>> >>> >> font selection backends were bad/useless on some platforms (like<br>
>> >>> >> windows see [1]). So I opted to try and use fontconfig on all<br>
>> >>> >> platforms as it performs outstandingly and has wonderful defaults<br>
>> >>> >> for<br>
>> >>> >> all platforms.<br>
>> >>> >><br>
>> >>> >> However during this transition I noticed that there are some major<br>
>> >>> >> issues with cache build speed and during investigation I see that<br>
>> >>> >> there has recently been effort to improve the situation[2]. From<br>
>> >>> >> what<br>
>> >>> >> I can tell the fontconfig team has maintained that these cache<br>
>> >>> >> issues<br>
>> >>> >> were irrelevent for the primary fontconfig platform (linux) [3]. On<br>
>> >>> >> linux of course the cache is global and maintained usually by font<br>
>> >>> >> packages ensuring its up-to-date. However it was precisely this the<br>
>> >>> >> slow cache build times that lead to package managers being required<br>
>> >>> >> to<br>
>> >>> >> build in additional tooling to support not rebuilding cache for<br>
>> >>> >> every<br>
>> >>> >> font installed [4].<br>
>> >>> >><br>
>> >>> >> Anyway I hope that is enough reason to persuade you that there are<br>
>> >>> >> substantial improvements to make to the caching strategy and they<br>
>> >>> >> are<br>
>> >>> >> beneficial not only for the odd platforms (osx, windows) but also<br>
>> >>> >> for<br>
>> >>> >> Linux.<br>
>> >>> >><br>
>> >>> >> My question is if fontconfig would be receptive to<br>
>> >>> >> building/accepting<br>
>> >>> >> a patch modifying the caching strategy to include checkums per file<br>
>> >>> >> instead of/in addition to per directory. Currently any change to<br>
>> >>> >> directory (such as adding a new font) invalidates all fonts within<br>
>> >>> >> that directory. This means for directories like the system<br>
>> >>> >> directory<br>
>> >>> >> it results in re scans of hundreds or more fonts. Thankfully this<br>
>> >>> >> is<br>
>> >>> >> faster on platforms like linux where all fonts on freetype. However<br>
>> >>> >> this improvement in scanning did not carry over to windows with its<br>
>> >>> >> many FNT (150 on the average install) and even on my very robust<br>
>> >>> >> development machine building a cache for a mere 650 files takes<br>
>> >>> >> half a<br>
>> >>> >> minute. This might be acceptable on install of the application<br>
>> >>> >> where<br>
>> >>> >> we can take our time building the cache, but what happens when a<br>
>> >>> >> user<br>
>> >>> >> installs 1 more font? A change to cache individual file checksums<br>
>> >>> >> would provide fontconfig a way to only require the expensive<br>
>> >>> >> coverage<br>
>> >>> >> check of a single font instead of the entirety of a users. I dare<br>
>> >>> >> say<br>
>> >>> >> with this exact change the need to use a faster less robust<br>
>> >>> >> coverage<br>
>> >>> >> check that made scanning freetype fonts faster may be unneeded as<br>
>> >>> >> the<br>
>> >>> >> number of scans required to rebuild a cache would reduced 100x on<br>
>> >>> >> the<br>
>> >>> >> average system or more.<br>
>> >>> >><br>
>> >>> >> I'm certain such a change would be highly appreciated by all<br>
>> >>> >> fontconfig consumers who are hoping to use its powerful feature set<br>
>> >>> >> in<br>
>> >>> >> a multiplatform context.<br>
>> >>> >><br>
>> >>> >> --Kurt Kartaltepe<br>
>> >>> >><br>
>> >>> >> [1] <a href="https://bugzilla.gnome.org/show_bug.cgi?id=162681" rel="noreferrer" target="_blank">https://bugzilla.gnome.org/<wbr>show_bug.cgi?id=162681</a><br>
>> >>> >> [2]<br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> <a href="https://lists.freedesktop.org/archives/fontconfig/2017-August/005986.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>archives/fontconfig/2017-<wbr>August/005986.html</a><br>
>> >>> >> [3] <a href="https://bugs.freedesktop.org/show_bug.cgi?id=64766" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=64766</a><br>
>> >>> >> [4]<br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> <a href="https://lists.freedesktop.org/archives/fontconfig/2007-October/002728.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>archives/fontconfig/2007-<wbr>October/002728.html</a><br>
>> >>> >> ______________________________<wbr>_________________<br>
>> >>> >> Fontconfig mailing list<br>
>> >>> >> <a href="mailto:Fontconfig@lists.freedesktop.org">Fontconfig@lists.freedesktop.<wbr>org</a><br>
>> >>> >> <a href="https://lists.freedesktop.org/mailman/listinfo/fontconfig" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/fontconfig</a><br>
>> >>> ><br>
>> >>> ><br>
>> >>> ><br>
>> >>> ><br>
>> >>> > --<br>
>> >>> > behdad<br>
>> >>> > <a href="http://behdad.org/" rel="noreferrer" target="_blank">http://behdad.org/</a><br>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> behdad<br>
>> >> <a href="http://behdad.org/" rel="noreferrer" target="_blank">http://behdad.org/</a><br>
><br>
><br>
><br>
><br>
> --<br>
> behdad<br>
> <a href="http://behdad.org/" rel="noreferrer" target="_blank">http://behdad.org/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">behdad<br><a href="http://behdad.org/" target="_blank">http://behdad.org/</a></div>
</div>