Bug 428583 - KMail Composer freezes intermittently on large messages with many quote lines
Summary: KMail Composer freezes intermittently on large messages with many quote lines
Status: REPORTED
Alias: None
Product: kmail2
Classification: Applications
Component: composer (show other bugs)
Version: 5.15.2
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-01 23:08 UTC by Brendon Higgins
Modified: 2020-11-01 23:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Observed call graph (cycle detection on) (85.25 KB, image/png)
2020-11-01 23:08 UTC, Brendon Higgins
Details
Observed call graph (cycle detection off) (155.03 KB, image/png)
2020-11-01 23:09 UTC, Brendon Higgins
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brendon Higgins 2020-11-01 23:08:42 UTC
Created attachment 132952 [details]
Observed call graph (cycle detection on)

Hi,

How to observe: Open kate, and make a new text document consisting of 2^13 lines of "test" (e.g., "test", RETURN, CTRL-A, CTRL-C, DOWN, CTRL-V, repeat 11 more times...). Paste that into new kmail composer window. Edit in composer, inserting lines randomly and adding whatever gibberish you like - things operate reasonably okay.

Now make 2^13 lines of "> test" (e.g., Replace All "test" with "> test"), paste it in, and try editing that. After a few seconds for me, the UI then freezes for a good 20 seconds. It will seem to come back, then freeze again after a few more seconds (it doesn't seem consistent). I feel like my Ryzen 3700X should be able to treat a few thousand lines of text with ease, but here we are.

I've had message chains between colleagues that end up like this - thousands of lines of quotes due to multiple rounds of HTML/text conversion and line splitting. Using one such example I had encountered, I tried doing a callgrind analysis for the time the composer was preparing to display the message. From that, I'm seeing two calls to QSyntaxHighlighter::rehighlight() are apparently turning into a few thousand calls to QSyntaxHighlighterPrivate::reformat, and in turn about 22 million calls to QTextDocumentLayoutPrivate::layoutBlock(). That seems like a lot, but I confess I'm not certain how to interpret the results (or the implication of "Cycle Detection" in KCachegrind), so I'll attach some call graph images in hopes it's useful.

For what it's worth, I have not found this effect in kate, even while the text is being syntax highlighted.


SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.74.0
Qt Version: 5.14.2
Comment 1 Brendon Higgins 2020-11-01 23:09:16 UTC
Created attachment 132953 [details]
Observed call graph (cycle detection off)