Bug 155212 - Writer is very slow when opening a file that includes embedded fonts
Summary: Writer is very slow when opening a file that includes embedded fonts
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.5.3.2 release
Hardware: x86-64 (AMD64) macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: perf
Depends on:
Blocks: File-Opening
  Show dependency treegraph
 
Reported: 2023-05-09 10:33 UTC by Chris Tapp
Modified: 2023-12-28 22:38 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
File without fonts (41.08 KB, application/vnd.oasis.opendocument.text)
2023-05-09 10:35 UTC, Chris Tapp
Details
File with fonts (5.71 MB, application/vnd.oasis.opendocument.text)
2023-05-09 10:35 UTC, Chris Tapp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Tapp 2023-05-09 10:33:53 UTC
Description:
I have two documents that use the same fonts (Open Sans, Courier New). One has the fonts embedded, the other does not, but they are otherwise identical (and basically empty).

Opening the document with the embedded fonts on an Intel Mac means that Writer goes unresponsive for several minutes. The document without the embedded fonts opens as expected.

Steps to Reproduce:
1.Open the "With-Fonts.odt" file that is attached to this ticket.
2.Open the "Without-Fonts.odt" file that is attached to this ticket.


Actual Results:
1.The "With-Fonts.odt" file takes ~290s to open - CPU is at 90%.
2.The "Without-Fonts.odt" file takes ~4s to open.


Expected Results:
The "With-Fonts.odt" file should take approximately the same amount of time to open.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Saving "With-Fonts.odt" also takes significantly longer. It would be reasonable for it to take a bit longer, but the times are ~15s vs 3s.

Version: 7.5.3.2 (X86_64) / LibreOffice Community
Build ID: 9f56dff12ba03b9acd7730a5a481eea045e468f3
CPU threads: 12; OS: Mac OS X 13.3.1; UI render: default; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: threaded
Comment 1 Chris Tapp 2023-05-09 10:35:18 UTC
Created attachment 187164 [details]
File without fonts
Comment 2 Chris Tapp 2023-05-09 10:35:45 UTC
Created attachment 187165 [details]
File with fonts
Comment 3 ⁨خالد حسني⁩ 2023-05-09 15:30:19 UTC
The file with fonts is indeed slower, but it is not that slow. One command line:


$ time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf Without-Fonts.odt
        2.93 real         1.85 user         0.62 sys

$ time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf With-Fonts.odt
       18.86 real        11.10 user         2.67 sys

So it takes 18 seconds not minutes.
Comment 4 Roman Kuznetsov 2023-05-09 18:21:58 UTC
hm...

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 69d0be09ad81935f7da4b6f8d036c3562357d068
CPU threads: 16; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: CL threaded

opens the File with fonts instantly

here is AMD Ryzen 5700U and Windows 10 on SSD

macOS only problem?
Comment 5 Chris Tapp 2023-05-10 09:39:41 UTC
(In reply to خالد حسني from comment #3)
> The file with fonts is indeed slower, but it is not that slow. One command
> line:
> 
> 
> $ time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> Without-Fonts.odt
>         2.93 real         1.85 user         0.62 sys
> 
> $ time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> With-Fonts.odt
>        18.86 real        11.10 user         2.67 sys
> 
> So it takes 18 seconds not minutes.

What system do you have? Running those commands here I get:

% time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf Without-Fonts.odt
   0.49s user 0.10s system 50% cpu 1.187 total

% time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf With-Fonts.odt
   0.55s user 0.32s system 0% cpu 20:32.21 total

Which shows embedded fonts is much slower - in fact, it is quicker to load the document and then export that it is to export from the command line.
Comment 6 Chris Tapp 2023-05-10 13:24:51 UTC
(In reply to Chris Tapp from comment #5)
> (In reply to خالد حسني from comment #3)
> > The file with fonts is indeed slower, but it is not that slow. One command
> > line:
> > 
> > 
> > $ time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> > Without-Fonts.odt
> >         2.93 real         1.85 user         0.62 sys
> > 
> > $ time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> > With-Fonts.odt
> >        18.86 real        11.10 user         2.67 sys
> > 
> > So it takes 18 seconds not minutes.
> 
> What system do you have? Running those commands here I get:
> 
> % time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> Without-Fonts.odt
>    0.49s user 0.10s system 50% cpu 1.187 total
> 
> % time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf
> With-Fonts.odt
>    0.55s user 0.32s system 0% cpu 20:32.21 total
> 
> Which shows embedded fonts is much slower - in fact, it is quicker to load
> the document and then export that it is to export from the command line.

Meant to add:

Which is strange, as it shows a much longer total time, but similar system and user times.
Comment 7 Chris Tapp 2023-05-10 13:46:55 UTC
I'm closing this as I'm now seeing a "reasonable" speed difference after restarting the system - it appears to be something within the OS, which is consistent with timings reported for the command line runs.

Thanks for the comments.
Comment 8 ⁨خالد حسني⁩ 2023-05-10 14:50:48 UTC
(In reply to Roman Kuznetsov from comment #4)
> macOS only problem?

Yes, it seems that we reload the system font list after loading each font from the document and this seems to be a bit slow on macOS.
Comment 9 Chris Tapp 2023-05-11 07:31:08 UTC
I've decided to reopen this as the problem reappeared shortly after the reboot, so it is not clear to me if the issue is with the system or writer.
Comment 10 Roman Kuznetsov 2023-05-11 07:34:02 UTC
Let's set it to NEW by Khaled's confirming
Comment 11 Chris Tapp 2023-05-11 11:04:17 UTC
More testing:

If LibreOffice is open, but there are no open documents:

% time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf With-Fonts.odt
   0.49s user 0.10s system 4% cpu 12.369 total

If LibreOffice is open and displaying Without-Fonts.odt:

% time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf With-Fonts.odt
   0.49s user 0.10s system 0% cpu 2:45.82 total

So, user and system time are the same, but there is a large increase in the total processing time.

If there are 6 documents open, then the total time increases even more (other timings the same):

% time /Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf With-Fonts.odt
   0.50s user 0.11s system 0% cpu 18:16.57 total

To me, this looks like there may be a lock related issue somewhere?