Closed Bug 1850305 Opened 8 months ago Closed 8 months ago

A js source compressor is 2.5x faster in Chrome compared to Nightly (and we spend a lot of time in Baseline)

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: mayankleoboy1, Assigned: jandem)

References

(Blocks 2 open bugs, )

Details

Attachments

(5 files)

Go to https://codegolf.github.io/zpng/
Set the number of iterations to 1
Copy and paste the sample .js file in the input box
Press "Compile" button

Nightly: https://share.firefox.dev/3QXkgU5 (86 seconds)
Chrome: https://share.firefox.dev/45KSCxF (34 seconds)

ER: Maybe faster.

Severity: -- → N/A
Priority: -- → P3

That ke function is pretty large but mostly runs in Baseline. Its size might have something to do with that, although there are some Ion samples of it so we probably do end up compiling it if the profile is correct.

NI myself to see if there's something weird going on with this function.

Flags: needinfo?(jdemooij)

This is a really good find, thanks for reporting this! It's a bailout issue caused by the type policy for MBooleanToInt32.

I have a fix, but I'm still looking into adding some assertions to the type policy code to catch similar issues.

I also have a shell version of this website that I'll attach to this bug. The fix improves that from ~85 seconds to ~16 seconds, almost exactly the same as what I get with an old V8 shell build.

Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Attached file Shell version

We were relying on MBooleanToInt32's type policy to insert a fallible unbox
for the to-boolean conversion. This caused a performance cliff because for
frequent TypePolicy bailouts we disable compilation instead of invalidating
the script.

The fix is to add the unbox instruction in the transpiler.

This fixes issues caught by the assertion added in the next patch. These operations
are actually infallible so didn't have the same performance cliff.

Depends on D187264

This would catch similar issues in the future and is a nice invariant to maintain.

Depends on D187265

Flags: needinfo?(jdemooij)
Keywords: leave-open
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e2d4c17692b7
part 1 - Fix a bailout performance cliff with GuardBooleanToInt32. r=iain

Mayank, can you confirm this is fixed in the latest Nightly?

Flags: needinfo?(mayankleoboy1)
Keywords: leave-open
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5fda6c22e8e3
part 2 - Add some infallible type conversions in the transpiler. r=iain
https://hg.mozilla.org/integration/autoland/rev/2689f838632f
part 3 - Add an assertion. r=iain

(In reply to Jan de Mooij [:jandem] from comment #10)

Mayank, can you confirm this is fixed in the latest Nightly?

Profile with latest nightly : https://share.firefox.dev/3EmVd5k (https://hg.mozilla.org/mozilla-central/rev/738c0a460acb30ab2ab419f4c0dc93fa9af200d6)
This shows no improvement for some strange reason. However, earlier today I had downloaded a opt build built from the link in comment #8, and that had showed 16 seconds. Not sure whats the reason why Nightly doesnt show the perf improvement.

I will retest in a couple of days when i have my regular laptop charger.

Flags: needinfo?(mayankleoboy1) → needinfo?(jdemooij)

(In reply to Mayank Bansal from comment #12)

Profile with latest nightly : https://share.firefox.dev/3EmVd5k (https://hg.mozilla.org/mozilla-central/rev/738c0a460acb30ab2ab419f4c0dc93fa9af200d6)
This shows no improvement for some strange reason. However, earlier today I had downloaded a opt build built from the link in comment #8, and that had showed 16 seconds. Not sure whats the reason why Nightly doesnt show the perf improvement.

I will retest in a couple of days when i have my regular laptop charger.

Mysterious. I just tested this locally with the latest Nightly and I got about 24 seconds. Your latest profile also shows that the ke function now spends almost all of its time in Ion.

Feel free to file a new bug if you're still seeing issues here.

Flags: needinfo?(jdemooij)
Flags: needinfo?(mayankleoboy1)

Backed out or causing assertion failures on TypePolicy.cpp

Backout link

Push with failures

Failure log

Flags: needinfo?(jdemooij)

(In reply to Mayank Bansal from comment #12)

(In reply to Jan de Mooij [:jandem] from comment #10)

Mayank, can you confirm this is fixed in the latest Nightly?

Profile with latest nightly : https://share.firefox.dev/3EmVd5k (https://hg.mozilla.org/mozilla-central/rev/738c0a460acb30ab2ab419f4c0dc93fa9af200d6)
This shows no improvement for some strange reason. However, earlier today I had downloaded a opt build built from the link in comment #8, and that had showed 16 seconds. Not sure whats the reason why Nightly doesnt show the perf improvement.

I will retest in a couple of days when i have my regular laptop charger.

I have no idea what I was thinking when I wrote this comment :| . I have some jetlag...

The profile in this comment is 32.9 seconds long. . So we are already faster than Chrome which took 34 seconds on my machine.

This bug improved the original testcase from 84 seconds -> 33 seconds which is a massive 2.5x improvement.
This bug is quite effectively fixed. Thanks :jandem for the fix!

Flags: needinfo?(mayankleoboy1)
Flags: needinfo?(jdemooij)
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/495c75053248
part 2 - Add some infallible type conversions in the transpiler. r=iain
https://hg.mozilla.org/integration/autoland/rev/7cbe6eba05b9
part 3 - Add an assertion. r=iain
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
Regressions: 1851976
Regressions: 1852702
Blocks: 1818669
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: