Testcase creating N empty text nodes is 380x slower in Nightly.
Categories
(Core :: DOM: Selection, defect)
Tracking
()
People
(Reporter: mayankleoboy1, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
Open testcase
Click go.
Bonus: click on normalize after you click go.
Generate
- Firefox: https://share.firefox.dev/4rl07Gn (16s)
- Chrome: https://share.firefox.dev/4t8YyNy (42ms)
Normalize
- Firefox: https://share.firefox.dev/4rvvOwZ (80s)
- Chrome: https://share.firefox.dev/46pZvqV (90s)
I am guessing from the profile that appending the text nodes triggers MutationObservers, which is known to be slow.
| Reporter | ||
Comment 1•6 days ago
|
||
This is a tangential testcase where textnodes are appended and un-appended.
Firefox: https://share.firefox.dev/3Z8ixhL (40s)
Chrome: https://share.firefox.dev/4a3QWmJ (20s)
Looks like that Jan is familiar with this kind of performance issue. However, it's unclear to me that this is about the performance issue of the mutation observer of nsRange or setting the new range to the new Text. I guess the former is more important than the latter. Moving the range to the new Text is required to get the slowness?
| Reporter | ||
Comment 3•6 days ago
•
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #2)
Moving the range to the new
Textis required to get the slowness?
Not sure what you mean. But if i comment out the the range lines, i still see slowness.
for (let i = 0; i < N; i++) {
const text = document.createTextNode("");
document.body.appendChild(text); // always append
const r = document.createRange();
/*Commented out
r.setStart(text, 0);
r.setEnd(text, 0);
ranges[i] = r;
*/
}
https://share.firefox.dev/4kfUOpp (14s)
Does this answer your question?
Yes, thanks. Range.setStart and Range.setEnd are not cheap so that their cost are also included in the previous profiles.
Now, it spends almost in DoublyLinkedList and style::gecko::wrapper::impl$8::prev_sibling. I'm not sure they are reasonable cost or not. Jan must be familiar with the former.
Description
•