Bug 114192 - Call psp::PrintFontManager::analyzeFontFile font scan only when needed
Summary: Call psp::PrintFontManager::analyzeFontFile font scan only when needed
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.4.2.2 release
Hardware: All Linux (All)
: medium normal
Assignee: ⁨خالد حسني⁩
URL:
Whiteboard: target:24.2.0
Keywords: bibisected, bisected, perf, regression
Depends on:
Blocks:
 
Reported: 2017-12-01 06:38 UTC by Anthony DeRobertis
Modified: 2023-08-08 13:08 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony DeRobertis 2017-12-01 06:38:21 UTC
At least on my system, every time I start LibreOffice, the startup time is mostly with the progress bar sitting in the middle & the disk pegged. Checking with strace & gdb, it appears that psp::PrintFontManager::analyzeFontFile is open/mmap/close'ing every font on the system (and read'ing a bunch too).

I had a pspfontcache file in my profile; just to confirm it wasn't corrupt, I deleted it. Even after a few restarts of LibreOffice, it hasn't been regenerated. I went ahead and deleted the entire psprint directory; that was recreated, but is now empty. I have no files name "pspfontcache" anywhere in $HOME.

PS: Not sure why this exists at all — shouldn't all this info be available from fontconfig? But that's surely a different bug, if a bug at all.
Comment 1 Anthony DeRobertis 2017-12-01 07:12:46 UTC
It appears pspfontcache was removed in babf6d5e53516e80e8e3f2485796ebfaeb20e9c1 ... 

Here, I timed it with a stopwatch, that font scan is ~30s on a cold cache. Even on a warm cache (from immediately closing & re-opening LibreOffice), it's ~20s.

$ fc-list | wc -l
4433

I'm sure that's part of the difference (10x as many fonts), but possibly the author & reviewers have SSDs as well? This machine has HDDs in RAID10, 16GiB RAM, and an i7-3770.
Comment 2 Kevin Suo 2017-12-01 10:46:42 UTC
Adding keyword  bisected regression.
Need someone to confirm whether is really slows down the starup.
Comment 3 ⁨خالد حسني⁩ 2017-12-01 22:04:16 UTC
The right fix is to stop calling psp::PrintFontManager::analyzeFontFile at startup and call it only when needed. AFAIK, we only need this information when creating PDF files.
Comment 4 Anthony DeRobertis 2017-12-03 18:38:10 UTC
Having a 30s delay to creating PDF files wouldn't be great, either, but it'd be much better than every startup.

I'd guess the information is all available from fontconfig anyway, which already has caches and can provide it basically instantly.
Comment 5 ⁨خالد حسني⁩ 2017-12-03 20:03:54 UTC
(In reply to Anthony DeRobertis from comment #4)
> Having a 30s delay to creating PDF files wouldn't be great, either, but it'd
> be much better than every startup.

I meant calling it on demand for the fonts we need, not every single font installed on the system.

> I'd guess the information is all available from fontconfig anyway, which
> already has caches and can provide it basically instantly.

I think some of the info needed can be taken from FontConfig, yes, but IIRC not all of them.
Comment 6 Xisco Faulí 2018-06-05 19:53:32 UTC
Adding Cc: to Khaled Hosny
Comment 7 Patrick Smits 2019-10-25 12:56:58 UTC
I'm having the same problem. Startup times of more than 30 seconds are no exception, even though the fonts are located on a SSD.

LibreOffice version 6.3.2.2 (on Arch Linux).
Comment 8 QA Administrators 2021-10-25 03:56:04 UTC Comment hidden (noise, obsolete)
Comment 9 Commit Notification 2023-08-03 17:56:30 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0b5e88bc88df6f0cd47e84cbd8bc53b649678f8b

tdf#114192: Speed up populating font list when FontConfig is used

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.