Bug 103291

Summary: noto-cjk takes 12 seconds to parse
Product: fontconfig Reporter: Alban Browaeys <prahal>
Component: libraryAssignee: fontconfig-bugs
Status: RESOLVED DUPLICATE QA Contact: Behdad Esfahbod <freedesktop>
Severity: normal    
Priority: medium CC: akira, freedesktop
Version: 2.12   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Alban Browaeys 2017-10-16 11:01:50 UTC
With https://tracker.debian.org/pkg/fonts-noto-cjk version 1:20170601+repack1-1 installed fontconfig takes more than 15 seconds to parse the fonts. If I remove this fonts, it is down to less than 3 seconds.
This with fontconfig from fc-2-12 branch commit 73c45cde5f9a7cfe1bdbb509e23ee487849a36bb installed. As far as I can tell it was even worst with stock debian 2.12.3-0.2 fontconfig so the latest speedup plays.


Could it be an issue with the fonts ? Or is it so heavy ?

Here is an extract with timestamp when fontconfig loads the noto-cjk fonts and they take around 12 seconds.

[pid     5] 22:32:47.128325 open("/usr/share/fonts/opentype/mathjax/MathJax_SansSerif-Italic.otf", O_RDONLY) = 5
[pid     5] 22:32:47.129141 open("/usr/share/fonts/opentype/mathjax/MathJax_SansSerif-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.129908 open("/usr/share/fonts/opentype/mathjax/MathJax_Script-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.131386 open("/usr/share/fonts/opentype/mathjax/MathJax_Size1-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.133549 open("/usr/share/fonts/opentype/mathjax/MathJax_Size2-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.134553 open("/usr/share/fonts/opentype/mathjax/MathJax_Size3-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.134903 open("/usr/share/fonts/opentype/mathjax/MathJax_Size4-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.135480 open("/usr/share/fonts/opentype/mathjax/MathJax_Typewriter-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.136571 open("/usr/share/fonts/opentype/mathjax/MathJax_WinChrome-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.136882 open("/usr/share/fonts/opentype/mathjax/MathJax_WinIE6-Regular.otf", O_RDONLY) = 5
[pid     5] 22:32:47.138185 open("/usr/share/fonts/opentype/noto", O_RDONLY|O_CLOEXEC) = 4
[pid     5] 22:32:47.138240 open("/var/cache/fontconfig//9b89f8e3dae116d678bbf48e5f21f69b-le64.cache-7", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid     5] 22:32:47.138285 open("/usr/share/fonts/opentype/noto", O_RDONLY|O_CLOEXEC) = 4
[pid     5] 22:32:47.138334 open("/var/cache/fontconfig//9b89f8e3dae116d678bbf48e5f21f69b-le64.cache-7", O_RDWR|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid     5] 22:32:47.138376 open("/usr/share/fonts/opentype/noto", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
[pid     5] 22:32:47.138469 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:47.631544 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:48.129769 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:48.614434 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:49.115903 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:49.611338 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:50.105648 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:50.597658 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:51.087194 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:51.558310 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:52.033531 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:52.506089 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:52.974375 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:53.445133 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:53.922897 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:54.393266 open("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:54.867025 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:55.599336 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:56.332699 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:57.064652 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc", O_RDONLY) = 5
[pid     5] 22:32:57.798153 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:58.526373 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc", O_RDONLY) = 5
[pid     5] 22:32:59.246956 open("/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc", O_RDONLY) = 5
evince-thumbnailer couldn't process file: 'file:///tmp/gnome-desktop-file-to-thumbnail.pdf'
Reason: Took too much time to process.
[pid     6] 22:32:59.557353 +++ exited with 0 +++
22:32:59.559397 +++ exited with 0 +++



This with nautilus calling evince-thumbnailer (in Gnome 3.26 this triggers in Bubblewrap sandboxing thus no cache is available).
Comment 1 Akira TAGOH 2017-10-16 11:11:55 UTC
The sort of this issue has been already improved in master but no plans to release it yet. what I can tell you at this moment is, when you install/update a font, you should run fc-cache in a timely manner, to avoid taking a time to update a cache in the runtime.

*** This bug has been marked as a duplicate of bug 64766 ***
Comment 2 Alban Browaeys 2017-10-16 14:25:47 UTC
Confirmed fixed with master branch.
Sorry I thought the fix was also in fc-2-12 branch per the latter was tagged 2.12.6 while master was still 2.12.5.
I am down to 3 seconds for the full set and thumbnail with noto-cjk !
Comment 3 Akira TAGOH 2017-10-17 07:45:53 UTC
that is the maintenance release branch of 2.12 and I'm not planning to push any drastic changes there. I initially ain't planning to maintain multiple branches though, can't made a release from master soon so made a branch from 2.12.5, but anyway.
Comment 4 Behdad Esfahbod 2017-10-17 18:10:57 UTC
(In reply to Alban Browaeys from comment #2)
> Confirmed fixed with master branch.
> Sorry I thought the fix was also in fc-2-12 branch per the latter was tagged
> 2.12.6 while master was still 2.12.5.
> I am down to 3 seconds for the full set and thumbnail with noto-cjk !

No idea what thumbnail is about, but with master, I get 0.1s for NotoSansCJK.ttc, ie the super OTC.
Comment 5 Alban Browaeys 2017-10-17 20:03:40 UTC
I have to admit the numbers are with strace wrapping evince-thumbnailer which slows down the process quite a lot.
With the master branch 3 seconds under strace v more than 15 seconds with or without strace for 2.12 one !
Mind that Gnome do run the thumbnailers in a Bubblewrap sandbox (thus no fontconfig cache as /var is not bind mounted).
So did I in my tests to nail down why evince-thumbnailer failed on me.
Comment 6 Behdad Esfahbod 2017-10-17 22:04:48 UTC
(In reply to Alban Browaeys from comment #5)
> I have to admit the numbers are with strace wrapping evince-thumbnailer
> which slows down the process quite a lot.
> With the master branch 3 seconds under strace v more than 15 seconds with or
> without strace for 2.12 one !
> Mind that Gnome do run the thumbnailers in a Bubblewrap sandbox (thus no
> fontconfig cache as /var is not bind mounted).
> So did I in my tests to nail down why evince-thumbnailer failed on me.

That sounds bad... Does the flatpak effort with fontconfig cache sharing also address bubblewrap usecase?
Comment 7 Akira TAGOH 2017-10-18 03:35:06 UTC
(In reply to Behdad Esfahbod from comment #6)
> That sounds bad... Does the flatpak effort with fontconfig cache sharing
> also address bubblewrap usecase?

If no bind-mounted cache dirs is there on the sandbox, that effort won't even help because you know fontconfig will *always* create a cache at the startup time right.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.