Closed Bug 1852540 Opened 2 years ago Closed 2 years ago

maybeGet* calls for builtin protos in CacheIR.cpp can cause performance issues

Categories

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

task

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [sp3])

Attachments

(1 file)

There are a few places in CacheIR.cpp where we attach a stub only if the global already has a certain builtin prototype object. This can cause a performance cliff especially with eager baseline interpreter/jit use (where I noticed this when looking into a fuzz bug).

Fixing this improves the micro-benchmark below from 50 ms to 13 ms for me.

function g() {}
function f() {
    var t = new Date;
    var arr = [1, 2, 3];
    for (var i = 0; i < 10_00_000; i++) {
        if (i > 20) {
            g(...arr);
        }
    }
    print(new Date - t);
}
f();

This fixes a performance cliff in some cases where we'd attach a slower stub instead.
This could happen with spread calls for example.

Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/77cef1514d20 Fix some CacheIR generators to create objects if needed instead of failing to attach. r=iain
Blocks: sm-jits
Severity: -- → N/A
Priority: -- → P2
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch

Oh nice, thanks for checking. I wasn't expecting this to be a measurable win on SP3, but good to see it maybe showed up anyway :)

Blocks: speedometer3
Whiteboard: [sp3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: