Open Bug 2013749 Opened 7 days ago Updated 5 days ago

Testcase creating N empty text nodes is 380x slower in Nightly.

Categories

(Core :: DOM: Selection, defect)

defect

Tracking

()

People

(Reporter: mayankleoboy1, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Attached file Empty text nodes.html

Open testcase
Click go.
Bonus: click on normalize after you click go.

Generate

Normalize

I am guessing from the profile that appending the text nodes triggers MutationObservers, which is known to be slow.

See Also: → 2013750
Summary: Testcase creating N empt text nodes is 380x slower in Nightly. → Testcase creating N empty text nodes is 380x slower in Nightly.

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?

Flags: needinfo?(mayankleoboy1)

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #2)

Moving the range to the new Text is 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?

Flags: needinfo?(mayankleoboy1)

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.

Flags: needinfo?(jjaschke)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: