Closed Bug 1943746 Opened 22 days ago Closed 2 days ago

Testcase generating large number of editable elements is 6x slower in Nightly. The time increases superlinearly with increase in number of element (45x slower with 3x element count)

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: mayankleoboy1, Unassigned)

References

(Depends on 1 open bug)

Details

Attachments

(2 files)

Attached file content editable.HTML

Open attached testcase
Enter 50000 and click on generate

Nightly: https://share.firefox.dev/3WwTJPo (5.4s)
Chrome: https://share.firefox.dev/40N2g3g (0.9s)

Maybe something to improve?
Testcase is generated using chatgpt.

Flags: needinfo?(masayuki)
Attached file about:support
Summary: Testcase generating large number of contenteditable elements is 6s slower in Nightly. The time increases superlinearly with increase in number of elements → Testcase generating large number of contenteditable elements is 6x slower in Nightly. The time increases superlinearly with increase in number of element (45x slower with 3x element count)

Hmm, this isnt really content-editable. It is just editable content.

Component: DOM: Editor → DOM: Core & HTML
Flags: needinfo?(masayuki)
See Also: → 1943230
Summary: Testcase generating large number of contenteditable elements is 6x slower in Nightly. The time increases superlinearly with increase in number of element (45x slower with 3x element count) → Testcase generating large number of editable elements is 6x slower in Nightly. The time increases superlinearly with increase in number of element (45x slower with 3x element count)

Looks like checking spellcheck attr is too slow due to checking ancestors and it may mishit especially in testcases.

Should we even spellcheck if the element is not focused?

In a test-case like:

data:text/html,<div contenteditable>foo bar baz</div><div contenteditable autofocus>foo bar baz</div>

Chrome only shows the spellcheck marks on the focused node. That would basically fix this, right?

Another alternative would be to use SelectNodeContents rather than SelectNode. Which should be faster and also work, right?

Surprising to me that this testcase highlights very different things compared to the "input element =text" testcase in bug 1943230

They use very different code-paths, so not that crazy :)

The improvements from bug 1943832 are glorious.

150000 elements : https://share.firefox.dev/4gdPiAc (4.1s) !
So from 135s -> 4.1s (32x faster)

Even better, in both the before and after profiles the spellchecking stuff takes ~3s . If you remove that, the after profile takes 971ms!
So 131s -> 971ms (134x faster!!)

Here is a partial profile for 10x the testcase 1500000 elements:
https://share.firefox.dev/3PR3nIZ

This is the breakdown:

  • Actual generation: 4.8s
  • Reflow: 5.3s.
  • Spellcheck stuff: 53s (partial)

Anything that can be fixed for the long tail of spellcheck stuff? I can file a new bug if needed.
Else, is there anything more to fix here?

ni? for comment 12.

Flags: needinfo?(emilio)

I think it's worth filing a bug for the spellcheck stuff... At the very least to try to spellcheck less (comment 6), but also there's some low hanging fruilt there (e.g. it seems mRealWords could benefit from being an AutoTArray, etc).

Flags: needinfo?(emilio)
Flags: needinfo?(mayankleoboy1)
Depends on: 1944275
Flags: needinfo?(mayankleoboy1)
Severity: -- → S3

Partial Profile with 1500000 elements: https://share.firefox.dev/3WNC1HD

(In reply to Mayank Bansal from comment #16)

Partial Profile with 1500000 elements: https://share.firefox.dev/3WNC1HD

Looks like there are only issues of the heavy allocations of the spellchecker. I don't know whether it's reasonable cost or not.

The only dependency is Bug 1944275, which doesnt have a clear path forward. But it can be independently tracked.

I will close this bug as FIXED. Thanks for all the work on this Masayuki and Emilio!

Status: NEW → RESOLVED
Closed: 2 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: