Closed Bug 1552356 Opened 6 years ago Closed 2 years ago

CSS Named Color "hue vs luminosity" chart demo is much slower in Firefox than in Chrome (with time spent in JS math code)

Categories

(Core :: JavaScript Engine: JIT, task, P3)

task

Tracking

()

RESOLVED WORKSFORME
Performance Impact low
Tracking Status
firefox68 --- affected

People

(Reporter: dholbert, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: perf, perf:responsiveness)

STR:

  1. Load https://comfortable-weeder.glitch.me/ in side-by-side Firefox vs. Chrome
  2. See how long it takes the animation to complete (filling out the whole color diamond) in each browser.

ACTUAL RESULTS:
Chrome takes ~10 seconds.
Firefox takes ~50 seconds.

EXPECTED RESULTS: we should be on par.

Here's a profile of Nightly for the first ~15 seconds of this load (during which time Chrome easily finishes the whole thing):
https://perfht.ml/30r8956

We're spending 50% of our time in the JS engine calling fdlibm::sqrt (called by fdlibm::hypot), as shown in this invert-stack view:
https://perfht.ml/30mqWi1

Note: this demo's author (Tab Atkins) is currently messing with it a bit, so it doesn't load anything interesting at all right now. He promises not to make it faster, though :) (per twitter thread at https://twitter.com/CodingExon/status/1129145052708519936 )

Anyway, hopefully it'll be back up and testable in time for whenever someone can take a look at this.

The problem is that the rasterize function is an async function, and that SpiderMonkey does not yet compile Generator / Async-functions with its optimizing JIT.

Moving the inner loop which loops over x in a separated function should improve by optimizing this inner function with the optimizing JIT and relying on the ecmaHypot function.

Component: JavaScript Engine → JavaScript Engine: JIT
Depends on: 1317690
Priority: -- → P3
Whiteboard: [qf?] → [qf]
Whiteboard: [qf] → [qf:p3:responsiveness]
Depends on: 1564117
Performance Impact: --- → P3
Whiteboard: [qf:p3:responsiveness]
Severity: normal → S3

This demo seems to run better these days. Daniel, what do you think?
https://share.firefox.dev/3WoZInu

Flags: needinfo?(dholbert)

Indeed it does! I just tested and Firefox seemed to be slightly faster than Chrome, actually. I'm guessing the "SpiderMonkey does not yet..." note from comment 2 has since been addressed.

Status: NEW → RESOLVED
Closed: 2 years ago
Flags: needinfo?(dholbert)
Resolution: --- → WORKSFORME

I ran mozregression to find the fix range. In old builds (e.g. comment 0's datestamp) I'm not seeing anything as bad as the 50-second time that I mentioned in comment 0 -- I'm seeing something like 5-6 seconds in newer builds, maybe 6-7 seconds in Chrome, vs. 8-12 seconds in older Firefox builds (with noticeably smaller progression per frame towards the end).

But that was still enough to find a fix range:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=b47dc08fc77ad2f26cee89a216c333ff490d195f&tochange=c6d819bd39daf86acd5e0c5bce5d74c2db8b8d64

That includes bug 1682623 "Enable Warp Compiled Generators and Async Functions", which sounds like it'd be what fixed this, based on comment 2.

Depends on: 1682623
You need to log in before you can comment on or make changes to this bug.