1.75x slower than Chrome computing style on NewsSite-Next + NewsSite-Nuxt
Categories
(Core :: CSS Parsing and Computation, enhancement)
Tracking
()
People
(Reporter: mstange, Unassigned)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
(Whiteboard: [perf-prio])
https://speedometer-preview.netlify.app/?suite=NewsSite-Nuxt&iterationCount=50
On the Speedometer 3 subtest "NewsSite-Nuxt", Firefox spends 1.75x as much time in mozilla::ServoStyleSet::StyleDocument as Chrome spends in blink::StyleEngine::RecalcStyle.
Firefox: https://share.firefox.dev/3YWCvLf 11376 samples
Chrome: https://share.firefox.dev/3sw5nho 6469 samples
Matching Chrome's speed on this part of the test would improve Firefox's overall score on NewsSite-Nuxt by 9.6%.
Updated•3 years ago
|
| Reporter | ||
Comment 1•3 years ago
•
|
||
A large part of that is in transition handling, which is covered under bug 1850812.
But if you subtract out Gecko_UpdateAnimations, we're still 1.3x slower:
Firefox: https://share.firefox.dev/3EgRGp8 8663 samples
Chrome: https://share.firefox.dev/3sw5nho 6469 samples
Closing the gap on just this part would improve Firefox's overall score on NewsSite-Nuxt by 4.3%.
| Reporter | ||
Updated•3 years ago
|
Updated•3 years ago
|
Comment 2•3 years ago
|
||
So I had a hunch about this when poking at the page, and visited link styling seems to add a lot of overhead to the cascade.
Markus, could I ask you to run the comparison with layout.css.visited_links_enabled=false and see if the difference goes away?
| Reporter | ||
Comment 3•3 years ago
|
||
Setting that pref to false reduces our style time by 7.5% from 4295 to 3973 samples, but Chrome's time is still quite a bit lower at 2578 samples.
Firefox with layout.css.visited_links_enabled=true, time spent in mozilla::ServoStyleSet::StyleDocument minus time spent in
Gecko_UpdateAnimations: https://share.firefox.dev/3Fx3Ta5 4295 samples
Firefox with layout.css.visited_links_enabled=false, time spent in mozilla::ServoStyleSet::StyleDocument minus time spent in Gecko_UpdateAnimations: https://share.firefox.dev/3Ffb3Q6 3973 samples
Chrome, time spent in blink::StyleEngine::RecalcStyle minus time spent in blink::StyleResolver::ApplyAnimatedStyle: https://share.firefox.dev/3txJu1S 2578 samples
| Reporter | ||
Comment 4•2 years ago
|
||
This is still the biggest bucket of difference on the NewsSite tests. Emilio, here's a comparison report of NewsSite-Next with today's Nightly, and also a comparison report with layout.css.visited_links_enabled=false. In the latter report, the difference in style time still amounts to 7.5% of the test overall.
Can you take another look?
Comment 5•2 years ago
|
||
So, some bits that stand out:
-
needs_transitions_updateis around 7.3% of the time inside style computation here. That is because approx. 20% of elements have atransition: all .3s ease. It seems we could speed this up quite a bit. I commented on bug 1876263 with an idea to remove that chunk ~completely. -
There's some other custom property substitution code that shows up a bunch. One potential idea to optimize that could be to store the original input indices in the variable reference set (so, make that something like a
HashMap<Name, SmallVec<[usize; 2]>or so, or perhaps something a bit smarter, or just a list of references). That should allow us to not re-tokenize during substitution, which seems like it should be a win, but not sure how big off-hand.
Comment 6•2 years ago
|
||
Any chance to get a comparison against chrome again?
| Reporter | ||
Comment 7•2 years ago
|
||
New comparisons: NewsSite-Next, NewsSite-Nuxt
Comment 8•2 years ago
|
||
The latest data suggests making Firefox as fast as Chrome on this function would reduce its time by 12.3%.
Comment 9•2 years ago
|
||
There are also some interesting things:
- The transitions issue in bug 1876263 is still relevant (not unexpected).
- Frame construction shows up a bit disproportionately for us (maybe hitting a slow path?)
- There are some quotes and counters updates that are a bit unexpected.
| Reporter | ||
Comment 10•2 years ago
•
|
||
On the new Windows machines we use in CI now, the difference in Update Style on NewsSite-Nuxt amounts to a 16% gap, and the factor is 2.2x.
| Reporter | ||
Comment 11•2 years ago
|
||
The biggest difference seems to be during this layout loop:
for (let i = 0; i < 25; i++) {
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
page.querySelector("#navbar-dropdown-toggle").click();
page.layout();
}
Here are profiles of that loop in one iteration, with Firefox having 26 samples and Chrome having 11 samples in Style during that loop. Are we restyling more elements when #navbar-dropdown-toggle is clicked?
Comment 12•2 years ago
|
||
here is a profile of nuxt running this 500 times:
for (let i = 0; i < 1000; i++) {
document.querySelector("#navbar-dropdown-toggle").click();
document.documentElement.getBoundingClientRect();
}
The number of elements doesn't seem particularly bad / seems about as expected, 5 when we hide it, 9 when we show it. Of those we don't selector-match all of them.
What takes a lot of time seems to be transition handling. That is a bit weird because there's effectively two elements transitioning, the two spans from:
<span class="animated-icon-inner" title="Arrow Icon"><span></span><span></span></span>
The submenu elements are either going from display: none or to display: none, so we shouldn't waste any time processing transitions for those.
Comment 13•2 years ago
|
||
Something trivial-ish I found (not a huge deal I don't think, but might help a bit):
Base revision's try run: https://treeherder.mozilla.org/jobs?repo=try&revision=73a9f30dd2124f3f17a6f54082a326aff7e95a55
Local revision's try run: https://treeherder.mozilla.org/jobs?repo=try&revision=a47caff9fb915d33dd9151835f665adcd6015330
Comment 14•10 months ago
|
||
(In reply to Emilio Cobos Álvarez [:emilio] from comment #12)
here is a profile of nuxt running this 500 times:
for (let i = 0; i < 1000; i++) { document.querySelector("#navbar-dropdown-toggle").click(); document.documentElement.getBoundingClientRect(); }The number of elements doesn't seem particularly bad / seems about as expected, 5 when we hide it, 9 when we show it. Of those we don't selector-match all of them.
What takes a lot of time seems to be transition handling. That is a bit weird because there's effectively two elements transitioning, the two spans from:
<span class="animated-icon-inner" title="Arrow Icon"><span></span><span></span></span>The submenu elements are either going from display: none or to display: none, so we shouldn't waste any time processing transitions for those.
Bug 1948933 has some optimization for display:none.
Comment 15•9 months ago
|
||
We've done a bunch of improvements here lately (bug 2014110 and related). Bug 2019782 would allow us to speed up the transition handling that shows up here.
Could we get an updated comparison report?
| Reporter | ||
Comment 16•8 months ago
|
||
It's now at the top of the list! https://protosaur.dev/perf-reports/html/Full-Sp3NUC-20260304.html
I'm not sure if that's because we got slower at it or Chrome got faster at it.
https://protosaur.dev/perf-reports/html/NewsSite-Next-Sp3NUC-20260304.html
https://protosaur.dev/perf-reports/html/NewsSite-Nuxt-Sp3NUC-20260304.html
Updated•8 months ago
|
| Reporter | ||
Comment 17•7 months ago
|
||
Updated profiles: https://share.firefox.dev/4vKd7by (Firefox) vs https://share.firefox.dev/41Mz9wM (Chrome)
Description
•