mozilla::ContentEventHandler::GetTextLength is still taking a lot of time on sp3 TipTap
Categories
(Core :: DOM: Editor, defect, P2)
Tracking
()
People
(Reporter: mstange, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Follow-up to bug 1838355.
Even with the changes from bug 1837482 and bug 1838355, the calls to ContentEventHandler::GetTextLength
remain the major bottleneck on the "Editor-TipTap" subtest of Speedometer 3.
Node.insertBefore
is 12x slower than in Chrome because of it.
Firefox: https://share.firefox.dev/43DZn2N
Chrome: https://share.firefox.dev/3rA2n31
Node.removeChild
is 9x slower than in Chrome because of it.
Firefox: https://share.firefox.dev/44T4PQm
Chrome: https://share.firefox.dev/44LXl1y
Eliminating these performance differences would improve our score on this subtest by 7.2%.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 1•2 years ago
|
||
Well, most time spends in ContentIteratorBase
due to its members are strong pointers. It could be fixable with making the class a template.
Comment 2•2 years ago
|
||
Reporter | ||
Comment 3•2 years ago
|
||
The patch from that try push does help, good!
It reduces the time spent in the two functions by 1.4x, which is a third of the difference.
insertBefore
before patch: ~3500 samples
insertBefore
after patch: ~2500 samples
insertBefore
in Chrome: ~250 samples
So the patch shaves off 1000 samples of the original difference of ~3000 samples, and should improve our numbers on the subtest by 2.4% (which is one third of 7.2%).
Here's a before/after report from the try push.
But Chrome doesn't appear to call anything like GetFlatTextLengthInRange
synchronously during the DOM mutation, so I wonder if we can do something similar.
Comment 4•2 years ago
|
||
Thank you for your check. I'll post the patch to a separate bug.
But Chrome doesn't appear to call anything like
GetFlatTextLengthInRange
synchronously during the DOM mutation, so I wonder if we can do something similar.
It's hard to say. We could put it off until sending the notification. However, once the DOM is updated during the tick, IME will receive wrong notifications and that leads their crash bugs.
Comment 5•2 years ago
|
||
I fixed the blocker bugs so need to reconsider whether this is still valid.
Reporter | ||
Comment 6•1 years ago
|
||
It's better but still a long ways off from Chrome. insertBefore and removeChild are still the top two functions where we are slower than Chrome on Editor-TipTap. Matching Chrome's performance would gain us 3.3% and 2.0% on Editor-TipTap.
Node.insertBefore
is now 8.6x slower than in Chrome.
Firefox: https://share.firefox.dev/3qD4Dq7
Chrome: https://share.firefox.dev/3OCDfAC
Node.removeChild
is now 6.5x slower than in Chrome.
Firefox: https://share.firefox.dev/3OxXcbI
Chrome: https://share.firefox.dev/45qB21K
Comment 7•1 years ago
|
||
Thank you.
So as smaug guessed, it takes a lot of time in converting nsAtom*
to nsHTMLTag
in both ContentEventHandler
and ContentIterator
.
Reporter | ||
Comment 8•1 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #7)
it takes a lot of time in converting
nsAtom*
tonsHTMLTag
I wonder if we could use an approach like this one in Chrome where they switch on the length first, then on the first character, and then do some memcmps for the remainder.
Reporter | ||
Comment 9•1 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #7)
it takes a lot of time in converting
nsAtom*
tonsHTMLTag
Bug 1849204 will probably improve the current hash table lookup, by decreasing the hashing cost. But the PLDHashTable::SearchTable
part would probably still remain, so the idea from the previous comment might still be worth trying.
Comment 10•1 years ago
|
||
Well, if we'd take the approach, it seems that we don't need TagAtomHash
anymore...
Description
•