Create text node buffers on the HTML parser thread (and check Latin1 and bidi there)
Categories
(Core :: DOM: HTML Parser, enhancement, P3)
Tracking
()
People
(Reporter: hsivonen, Unassigned)
Details
Updated•6 years ago
|
Updated•3 years ago
|
| Reporter | ||
Comment 1•9 months ago
•
|
||
I measured time spent in SetText as a proportion of the time spent with nsHtml5AutoFlush live.
For ad iframes and some background documents from Web Extensions, the time spent is negligible.
Other than that, the time spent seems to vary from 2% (Amazon front page) to 16% (HTML spec on Android) with app-like pages landing in the low end of that range and document-like pages landing from middle to high end of that range.
The time the HTML parser spends building the DOM on the main thread is tiny in comparison to the time spent in layout. In that sense, one might argue against putting effort into parser optimizations. However, we have mechanisms to avoid nsHtml5TreeOpExecutor::RunFlushLoop occupying the main thread: We have time-based yielding and pending user event-based yielding to the event loop (since last century, I believe) and we have de-prioritization of background pages (since 2012).
Both predate current hardware and Fission, but if we believe that these mechanisms to avoid nsHtml5TreeOpExecutor::RunFlushLoop occupying the main thread continue to be worthwhile, it should be worthwhile to reduce that time by 2% to 16%.
To get the measured benefit, we should not only move the Latin1 and bidi checks to the parser thread but we should allocate and fill the text buffer for the text node on the parser thread in a form that can be adopted into the text node.
The main complication is that our text nodes have the optimization that the buffer of a whitespace-only text node can be shared with other text nodes that happen to contain the same whitespace. Some of this consolidation computation would have to continue to happen on the main thread if we want to continue to have this memory optimization more broadly than only across the parser thread-created text nodes.
| Reporter | ||
Updated•9 months ago
|
Description
•