"Reply" or "reply all" is slow for large messages - O(n^2) performance
Categories
(Thunderbird :: Message Compose Window, defect)
Tracking
(Not tracked)
People
(Reporter: marcia, Unassigned)
References
Details
(Keywords: perf, Whiteboard: [see comment 20, 23])
Comment 1•20 years ago
|
||
Reporter | ||
Comment 2•20 years ago
|
||
Comment 3•20 years ago
|
||
Comment 4•20 years ago
|
||
Comment 5•20 years ago
|
||
Comment 6•20 years ago
|
||
Comment 7•20 years ago
|
||
Comment 8•20 years ago
|
||
Reporter | ||
Comment 9•20 years ago
|
||
Comment 10•20 years ago
|
||
Comment 11•20 years ago
|
||
Comment 12•20 years ago
|
||
Updated•20 years ago
|
Comment 13•20 years ago
|
||
Comment 14•19 years ago
|
||
Comment 15•19 years ago
|
||
Comment 16•19 years ago
|
||
Comment 17•19 years ago
|
||
Comment 18•19 years ago
|
||
Comment 19•19 years ago
|
||
Comment 20•19 years ago
|
||
Updated•18 years ago
|
Comment 21•17 years ago
|
||
Comment 22•16 years ago
|
||
Comment 23•16 years ago
|
||
Updated•14 years ago
|
Comment 26•14 years ago
|
||
Comment 27•13 years ago
|
||
Comment 28•10 years ago
|
||
Comment 30•3 years ago
•
|
||
I can replicate this issue by hitting "reply" to a message in a local folder. The message contains lots of broken-up quotes, like so:
...
> a quoted line
..blank...
> another quoted line
... etc etc...
The slowdown occurs when the message I'm replying to is being inserted into the HTML editor DOM, using HTMLEditor::InsertAsCitedQuotation()
.
It quickly creates a documentFragment with the HTML elements it wants to insert, then loops through, adding them into the DOM.
It's inserting elements into the DOM which seems to be slow. My test message takes 10 mins or so.
The test email I'm using is a pretty awful one, but it's a form you'd often find out in the wild - a long thread with lots of top-posting, and all the quoted lines interleaved with blank lines somewhere along the way by some . It comes out as about 80000 HTML elements (Mostly <pre>
and <blockquote>
elements I think).
There's a similar story with plain-text composition - it still generates HTML elements in a similar way for each bit of quoted content, so it's not just a matter of inserting one big element. You still end up with a comparable number of elements to insert.
You can see the elements being added with the log - MOZ_LOG="EditorTransaction:5"
Now. 80000 DOM nodes is a good number... but it still seems awfully slow to me. From what I can tell it's spending the bulk of it's time in
InsertNodeTransaction::DoTransaction(), which spends all it's time inside Selection::CollapseInLimiter(), which ends up dividing the time between nsINode::SetBoolFlag() and nsINode::ClearBoolFlag().
So, my guess is something selection-related slowing it down. I thought it might be registered Selection listeners causing trouble, but that doesn't seem to be the case (I commented out the notification call and it was still slow). I'm out of ideas for now.
Magnus: this would benefit from having some input from someone who knows about HTMLEditor - any thoughts who?
Comment 31•3 years ago
|
||
:masayuki is the editor expert.
Any suggestions?
Comment 32•3 years ago
|
||
I'd be nice if the profile is public and there is a testcase to reproduce it in mochitest. Anyway, editor creates transaction instances and modifies connected trees too many times. And also editor depends on selection, therefore, needs to update selection everywhere, that's also causes slowness because of Selection API cost.
So, bug 1555919 and bug 1624587 are the root cause, but perhaps, we can fix it with some simple patches if the bottlenecks are only a few places.
Description
•