Firefox is 6x slower than Chrome on a testcase that matches attributes (early rejection test)
Categories
(Core :: CSS Parsing and Computation, defect, P3)
Tracking
()
People
(Reporter: mayankleoboy1, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
|
7.64 KB,
text/html
|
Details |
Open testcase
Create DOM
Click on "2. CSS fast path"
Firefox: https://share.firefox.dev/4fqHEWp (23s)
Chrome: https://share.firefox.dev/4ayCbJE (4.2s)s
| Reporter | ||
Comment 1•5 months ago
|
||
:emilio, what do you think?
Comment 2•5 months ago
|
||
I think it's expected. Blink's invalidation is a lot simpler which performs better on this test-case on which there's nothing to invalidate, but they over-invalidate in a bunch of cases where we can prove that style hasn't changed.
Comment 3•5 months ago
|
||
Something we could try to do is using the querySelector bloom filter to try to skip some of the dependencies. Not sure how much that would improve in practice.
Updated•5 months ago
|
| Reporter | ||
Comment 4•5 months ago
|
||
Profile: https://share.firefox.dev/4vmRjCz (23s)
| Reporter | ||
Comment 5•4 months ago
|
||
A descendant invalidation is carried down through an entire subtree,
matching its compound against every element on the way. When the compound
names something the subtree provably doesn't contain, all of that work is
wasted: on the testcase in the bug, toggling a class on the root of a
200k node subtree runs eight such invalidations over every element,
none of which can match.
Reuse the subtree filter hashes added for bug 2005808 to reject those
invalidations at the top of the subtree instead. The filter covers the
child and everything below it, so a miss means neither the child nor any
of its descendants can match, and therefore nothing there can generate
further invalidations either.
That last part is only true if the filter covers everything the
invalidator traverses, so propagate it across shadow roots as well:
querySelector doesn't look into those, so for it this only means a few
more false positives, but style invalidation does walk them. Native
anonymous content is already covered, since it is bound with the element
as its DOM parent.
Three things worth a reviewer's attention:
Invalidation grows from 40 to 56 bytes, because the hashes are stored
twice (classes match ASCII case-insensitively in quirks mode while the
DOM hashes them as authored, so the quirks set leaves them out).
DescendantInvalidationLists is three SmallVec<[Invalidation; 10]> and is
default-constructed per invalidate_child, so this costs roughly 480 extra
bytes of stack per level of a recursion that already needs a
StackLimitChecker, plus a wider copy per clone on the path where nothing
gets rejected. It can be brought down to a single u64 by resolving quirks
mode at construction time and threading QuirksMode through the
Invalidation::new callers; that is not done here because the cost is
unmeasured and the plumbing is not obviously worth it.
Crossing shadow roots when propagating weakens the querySelector
optimization bug 1997380 landed, by adding false positives on
shadow-heavy pages. The alternative would be to leave propagation alone
and gate the skip on there being no shadow host anywhere in the subtree,
but there is no cheap signal for that today.
None of this has been measured. What can be said from the source alone is
that #tree-slow in the testcase is already skipped today, since
should_process_descendants bails on is_display_none(), so the reported
time is #tree-fast; and that #tree-fast's filter holds four distinct
atoms, i.e. 8 of 63 bits, so a two-bit query hash is very unlikely to
collide. That is a mechanism, not a number, and no percentage is being
claimed until it is run.
Comment 6•4 months ago
|
||
Comment on attachment 9616069 [details]
WIP: Bug 2045461 - Use the DOM subtree filter to skip descendant invalidation subtrees. r?#firefox-style-system-reviewers,#dom-core
Revision D314249 was moved to bug 2005808. Setting attachment 9616069 [details] to obsolete.
| Reporter | ||
Comment 7•4 months ago
|
||
Updated•4 months ago
|
| Reporter | ||
Comment 8•4 months ago
|
||
Performance with the whole stack applied: https://share.firefox.dev/4yKc8tD (250ms)
| Reporter | ||
Comment 9•1 month ago
|
||
Analyze the testcase and posted patches. Explore if a better/stronger/broader/simpler/higher-level design can be created. Then create a single patch for that.
Comment 10•1 month ago
|
||
Clearing the needinfo request since it is pending on an account that cannot answer (a bot, a component watcher, or a disabled account).
For more information, please visit BugBot documentation.
Updated•24 days ago
|
Description
•