Closed
Bug 1396575
Opened 7 years ago
Closed 6 years ago
Track performance for creating an autonomous custom elements which doesn't match CE definition
Categories
(Core :: DOM: Core & HTML, enhancement, P2)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: jdai, Unassigned)
References
Details
Attachments
(1 file)
1.12 KB,
text/html
|
Details |
+++ This bug was initially created as a follow-up of bug 1299363 comment #77 +++ * The nearly-normal case (createElement, with the changes, define() call, one arg), is also much slower than what we have now. Needs to be profiled, understood, and fixed: the one-arg case should have no performance penalty, I would think. Performance detail result: https://docs.google.com/a/mozilla.com/spreadsheets/d/1OLntq8Qd4e4td7ml6iq0r1sVxl4phMta3HFAAMvpAms/edit?usp=sharing
Updated•7 years ago
|
Priority: -- → P2
Reporter | ||
Comment 1•7 years ago
|
||
This bug is for nearly-normal case (createElement, with the changes, define() call, one arg) that is we defined a custom element, but createElement doesn't use that defined custom element to create. Ex: class FooElement extends HTMLDivElement { constructor() { super(); } }; customElements.define("x-foo", FooElement, { extends: "div" }); document.createElement("div"); And the bug title will be moved to bug 1419661.
Summary: CreateElement with define() call and it'll run upgrade which is much slower than what we have now → When custom elements preference is on, createElement with define() call, one arg is also much slower than what we have now
Comment 2•6 years ago
|
||
(In reply to John Dai[:jdai] from comment #1) > This bug is for nearly-normal case (createElement, with the changes, > define() call, one arg) that is we defined a custom element, but > createElement doesn't use that defined custom element to create. Ex: > > class FooElement extends HTMLDivElement { > constructor() { > super(); > } > }; > customElements.define("x-foo", FooElement, { extends: "div" }); > > document.createElement("div"); This creates a normal element and this case is already tracked in bug 1396573. I guess this bug is filed for "creating a custom element which doesn't match with any existing definition". So perhaps, the test should be "document.createElement("x-foo");" ?
Flags: needinfo?(jdai)
Reporter | ||
Comment 3•6 years ago
|
||
(In reply to Edgar Chen [:edgar] from comment #2) > (In reply to John Dai[:jdai] from comment #1) > > This bug is for nearly-normal case (createElement, with the changes, > > define() call, one arg) that is we defined a custom element, but > > createElement doesn't use that defined custom element to create. Ex: > > > > class FooElement extends HTMLDivElement { > > constructor() { > > super(); > > } > > }; > > customElements.define("x-foo", FooElement, { extends: "div" }); > > > > document.createElement("div"); > > This creates a normal element and this case is already tracked in bug > 1396573. > I guess this bug is filed for "creating a custom element which doesn't match > with any existing definition". > So perhaps, the test should be "document.createElement("x-foo");" ? Maybe we can consider this bug is for creating an autonomous custom element or a customized built-in element which doesn't match with any existing definition. Does that make sense?
Flags: needinfo?(jdai)
Comment 4•6 years ago
|
||
(In reply to John Dai[:jdai] from comment #3) > Maybe we can consider this bug is for creating an autonomous custom element > or a customized built-in element which doesn't match with any existing > definition. Does that make sense? I thought bug 1419660 is filed for creating a customized built-in element which doesn't match with any existing definition?
Flags: needinfo?(jdai)
Reporter | ||
Comment 5•6 years ago
|
||
(In reply to Edgar Chen [:edgar] from comment #4) > (In reply to John Dai[:jdai] from comment #3) > > Maybe we can consider this bug is for creating an autonomous custom element > > or a customized built-in element which doesn't match with any existing > > definition. Does that make sense? > > I thought bug 1419660 is filed for creating a customized built-in element > which doesn't match with any existing definition? Bug 1419660 is for creating a customized built-in element with no define() calls(testcase [1]). We can separate creating a customized built-in element which doesn't match with any existing definition to another bug if it'll make this bug more clear. [1] https://edgarchen.github.io/tests/CustomElements/Performance/CreateElement/Builtin/no_definition_two_arg_with_is.html
Flags: needinfo?(jdai)
Reporter | ||
Comment 6•6 years ago
|
||
Per off-line discussion, this bug is for creating an autonomous custom elements which doesn't match CE definition. We can consider CE preference is on/off case for document.createElement("x-foo").
Summary: When custom elements preference is on, createElement with define() call, one arg is also much slower than what we have now → Track performance for creating an autonomous custom elements which doesn't match CE definition
Comment 7•6 years ago
|
||
Comment 8•6 years ago
|
||
Quick test attachment #894177 on recent m-c, 05fed903f40f pref-off: ~33ms pref-on: ~54ms In pref-on case, definition lookup is one possible operation that makes the createElement() slower. But I am not sure if there are others, need to do more investigation.
Comment 9•6 years ago
|
||
Test: attachment #8941774 [details] with pref-on Base revision: 6f9b763bb1c9 Profile: https://perfht.ml/2DfQqWg
Comment 10•6 years ago
|
||
From profile [1] in comment #9, I found we spend some time atomizing aLocalName when looking up definition [2]. And the caller usually pass nodeInfo->LocalName() as aLocalName, like [3]. I wondering if we could use nodeInfo->NameAtom() given that these code is only called with element's nodeInfo which the LocalName() and NameAtom() should be the same value. Does this make sense? [1] https://perf-html.io/public/708b78ee5c83e942269ea6b20795464b61337624/calltree/?hiddenThreads=&invertCallstack&range=2.6524_2.7236&thread=5&threadOrder=0-2-3-4-5-1&transforms=f-combined-xAi-i&v=2 [2] https://searchfox.org/mozilla-central/rev/41925c0b6c6d58578690121de439d2a8d3d690f3/dom/base/CustomElementRegistry.cpp#290 [3] https://searchfox.org/mozilla-central/rev/41925c0b6c6d58578690121de439d2a8d3d690f3/dom/base/nsContentUtils.cpp#10012
Flags: needinfo?(bugs)
Comment 11•6 years ago
|
||
Sounds reasonable given that we're dealing with elements https://searchfox.org/mozilla-central/rev/48cbb200aa027a0a379b6004b6196a167344b865/dom/base/NodeInfo.cpp#79,89
Flags: needinfo?(bugs)
Comment 12•6 years ago
|
||
(In reply to Olli Pettay [:smaug] (please try to find other reviewers for non-web components patches) from comment #11) > Sounds reasonable given that we're dealing with elements > https://searchfox.org/mozilla-central/rev/ > 48cbb200aa027a0a379b6004b6196a167344b865/dom/base/NodeInfo.cpp#79,89 Filed bug 1430951. Thank you!
Depends on: 1430951
Comment 13•6 years ago
|
||
Another found: we spend some time AddRef()ing and Release()ing of atoms in nsContentUtils::NewXULOrHTMLElement [1], some is from https://searchfox.org/mozilla-central/rev/48cbb200aa027a0a379b6004b6196a167344b865/dom/base/nsContentUtils.cpp#9994. It seems we could just use raw pointer there given that the atom is owned by nodeInfo, but I am not not sure how much this could improve. [1] https://perf-html.io/public/708b78ee5c83e942269ea6b20795464b61337624/calltree/?hiddenThreads=&invertCallstack&range=4.8478_4.9187&thread=5&threadOrder=0-2-3-4-5-1&v=2
Comment 14•6 years ago
|
||
We've fixed the obvious cases. One thing which would help is faster slots allocation. Testcase is faster in Gecko than in Blink. Marking fixed for now.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•