avoid creating the Forms and FormControls content lists when we can
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox69 | --- | fixed |
People
(Reporter: heycam, Assigned: heycam)
References
(Regressed 2 open bugs)
Details
(Keywords: perf)
Attachments
(2 files)
Looking at a profile of the HTML spec loading, we spend 150ms (or about 2% of the load time) under nsINode::CompareDocumentPosition in response to elements being inserted into the document from the parser, so that we can potentially update the document's Forms and FormControls nsContentLists eagerly rather than just marking them as dirty. These nsContentLists exist due to GenerateStateKey being called for form controls just after they are created. I see that bug 314117 made us avoid calling GenerateStateKey unless we knew we had state to restore, but perhaps we regressed that.
| Assignee | ||
Comment 1•6 years ago
|
||
(In reply to Cameron McCormack (:heycam) from comment #0)
I see that bug 314117 made us avoid calling
GenerateStateKeyunless we knew we had state to restore, but perhaps we regressed that.
I mean bug 388387.
| Assignee | ||
Updated•6 years ago
|
| Comment hidden (obsolete) |
| Assignee | ||
Comment 3•6 years ago
|
||
| Assignee | ||
Comment 4•6 years ago
|
||
| Assignee | ||
Comment 5•6 years ago
|
||
| Assignee | ||
Comment 6•6 years ago
|
||
So I think the approach in this patch isn't going to work. By delaying the call to GenerateStateKey from the point the element is first inserted into the document to some later point when we want to capture its state, we can end up generating a different state key. (The element may have moved around, or other elements inserted before it, causing the part of the key that comes from its index in the FormControls content list to be different.)
We only do this on insertion for parser generated elements. Given that, I wonder if we could change the key so that instead of using its index in FormControls, we instead use some counter that is incremented on the document. That should preserve the same order for those parser generated elements. For non-parser generated elements inserted into the document later, we could continue to use the index in FormControls (although that is still not great for perf with very large documents like this), as long as the state keys for the parser generated elements were distinct from the non-parser generated ones.
| Assignee | ||
Comment 7•6 years ago
|
||
Updated patches to do that:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=541009241fa634373b4b2c44598a9eb636406340
Updated•6 years ago
|
Updated•6 years ago
|
| Assignee | ||
Comment 8•6 years ago
|
||
Comment 10•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/dd6e7c0970d5
https://hg.mozilla.org/mozilla-central/rev/fbb26a04ec1f
Comment 11•6 years ago
|
||
Backed out for causing Bug1562142
Backout link: https://hg.mozilla.org/integration/autoland/rev/1ddc47f7370187b3a07d61a65f9f0fd19e7e20a5
Updated•6 years ago
|
| Assignee | ||
Comment 12•6 years ago
|
||
The regression flagged in bug 1562142 showed a lot of time spent under GenerateStateKey when running Speedometer. There, the form control elements are inserted into the document not by the parser coming from the network, which means we do the slow "find the position of the form control in the document using an nsContentList" thing. But my patch makes us call GenerateStateKey more often (specifically, the calls is moved out of the if (!mInhibitRestoration) checks). So I need to remember why I did that...
| Assignee | ||
Comment 13•6 years ago
|
||
Comment 14•6 years ago
|
||
Comment 15•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/02312da6f1ca
https://hg.mozilla.org/mozilla-central/rev/d65cbaac955b
Description
•