Bug 114498 - EDITING: Slow down when editing text in document with content.xml text styles non-existent in styles.xml
Summary: EDITING: Slow down when editing text in document with content.xml text styles...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.1 all versions
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: perf
Depends on:
Blocks: Performance CPU-AT-100%
  Show dependency treegraph
 
Reported: 2017-12-16 15:37 UTC by LotusDev
Modified: 2024-04-25 06:39 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Test file exhibiting the slow down problem (46.69 KB, application/vnd.oasis.opendocument.text)
2017-12-16 15:38 UTC, LotusDev
Details
Callgrind output from master (6.90 MB, application/x-xz)
2018-02-19 14:07 UTC, Buovjaga
Details
Screenshot (388.76 KB, image/jpeg)
2018-02-19 22:03 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description LotusDev 2017-12-16 15:37:17 UTC
Description:
After much investigation I realised that the structure of the file itself is part of the problem. If I copy paste the file in a standard text editor and paste it back into LO it works without issue. I can't seem to figure out what's the problem with the file structure itself someone with more knowledge will have to continue. I have tried all version from 5.1.x to 5.4.x and they all have the same problem. The slow down seem to be different when editing different place in the file but right at the beginning is a good example. The hardware should not be a problem as it is on a recent quad core machine. 

Steps to Reproduce:
1. Open attached file
2. Edit document at the beginning of file
3.

Actual Results:  
Lag and latency above what I would consider normal

Expected Results:
No perceived latency when editing


Reproducible: Always


User Profile Reset: No



Additional Info:


User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
Comment 1 LotusDev 2017-12-16 15:38:15 UTC
Created attachment 138476 [details]
Test file exhibiting the slow down problem
Comment 2 LotusDev 2017-12-16 15:40:20 UTC
For reference this was on Ubuntu 16.04.
Comment 3 Telesto 2017-12-16 16:55:03 UTC
Confirming the slowness (and high CPU usage)
Version: 6.1.0.0.alpha0+
Build ID: aad9c6da5154a89c6ef02214d1122d4b444eea23
CPU threads: 4; OS: Windows 6.3; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-12-15_22:56:44
Locale: nl-NL (nl_NL); Calc: CL

Fast but still high CPU usage with:
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

Copy/Pasting the text as unformatted text into a new document will resolve the issue
Comment 4 Telesto 2018-02-17 19:56:05 UTC
A valgrind trace would be nice ;-)
Comment 5 Buovjaga 2018-02-19 13:57:33 UTC
In the beginning of content.xml there is:

<text:span text:style-name="T1">Le</text:span>
<text:span text:style-name="T2">cture #1</text:span>
<text:span text:style-name="T1">. </text:span>
<text:span text:style-name="T3">This </text:span>
<text:span text:style-name="T4">is is the problem </text:span>
<text:span text:style-name="T5">with the problem</text:span>
Comment 6 Buovjaga 2018-02-19 14:07:29 UTC
Created attachment 139993 [details]
Callgrind output from master

First deleted some text and then typed to another location in the beginning (with the split spans).

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: c902cbc7dc5294ab721a9aef3a152aa243d00011
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on February 17th 2018
Comment 7 Telesto 2018-02-19 15:46:19 UTC
@Khaled
Would you mind to take a short peek at the callgrind trace. It looks quite a lot like bug 112989. However, existing already before Harfbuzz. Thanks!
Comment 8 ⁨خالد حسني⁩ 2018-02-19 18:35:38 UTC
It is a well known fact that our text layout performance is sub-optimal; the code was written long ago with the assumption that text layout is cheap and can be re-done whenever needed, but that is not the case any more and and overhaul is long over due. I’m pretty sure this was mentioned before somewhere.
Comment 9 Telesto 2018-02-19 22:03:23 UTC
Created attachment 140009 [details]
Screenshot

(In reply to Khaled Hosny from comment #8)
> It is a well known fact that our text layout performance is sub-optimal; the
> code was written long ago with the assumption that text layout is cheap and
> can be re-done whenever needed, but that is not the case any more and and
> overhaul is long over due. I’m pretty sure this was mentioned before
> somewhere.

You did.. Should have been more specific with my question. Sorry! I'm not quite sure if this is really about the text layout at all. Could be more or less unrelated. The main problem could be segmentation fault: I'm noticing _dl_runtime_resolve_xsave'2 (I have add a screenshot)

Anyway thanks for the quick response!
Comment 10 Timur 2018-02-20 08:19:10 UTC
(In reply to Buovjaga from comment #5)
> In the beginning of content.xml there is:
> 
> <text:span text:style-name="T1">Le</text:span>
> <text:span text:style-name="T2">cture #1</text:span>
> <text:span text:style-name="T1">. </text:span>
> <text:span text:style-name="T3">This </text:span>
> <text:span text:style-name="T4">is is the problem </text:span>
> <text:span text:style-name="T5">with the problem</text:span>

Redundant styles, but I think real issue is that those styles are not defined in styles.xml. Saw similar in attachment 120477 [details] from Bug 95633. I wonder how those docs were created (probably wrong, by formatted copying). Guess Writer is checking back and forth in vain. 
So if I understand this, we may wait for an overhaul or do something if styles are not defined.
Comment 11 QA Administrators 2019-08-19 06:58:42 UTC Comment hidden (obsolete)
Comment 12 LotusDev 2019-08-19 11:08:47 UTC
This bug is still present now under Ubuntu 18.04 LTS and LibreOffice version

Version: 6.2.5.2
Build ID: 1:6.2.5-0ubuntu0.18.04.1~lo1

However, I had not look at the time at the file of bug 95633 discussed in comment #10 but the problem is much more noticeable in this file.
Comment 13 QA Administrators 2021-08-19 03:44:13 UTC Comment hidden (obsolete)
Comment 14 LotusDev 2021-08-20 13:12:34 UTC
I tested this now under 7.1.5.2 and the bug is no longer present, we can close this.