Closed Bug 1858679 Opened 9 months ago Closed 9 months ago

Callee guard for self-hosted lambda functions can cause unnecessary guard failures and bailouts/recompiles

Categories

(Core :: JavaScript Engine: JIT, task)

task

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox120 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(2 files)

In IRGenerator::emitCalleeGuard, we currently always emit GuardSpecificFunction for self-hosted builtins. This is the right thing in most cases, but not for self-hosted lambda functions such as the one returned by ArraySortCompare, because we'll attach a new Baseline IC stub for each clone and this can cause unnecessary bailouts and recompiles.

Below is a simple example where we do 24 Warp compilations (according to IONFLAGS=scripts). Fixing this reduces it to 14.

function f() {
    var a = [];
    for (var i = 0; i < 2000; i++) {
        a.push({x: i});
    }
    for (var i = 0; i < 10; i++) {
        a.sort((a, b) => a.x - b.x);
    }
}
f();
Whiteboard: [sp3]

We were always emitting GuardSpecificFunction for self-hosted functions, but this
doesn't work well for self-hosted lambda functions because there we have lambda clones
and we want to guard on the script instead.

Lambdas aren't very common in self-hosted code, but ArraySortCompare returns a lambda
function and that's where it was causing unnecessary bailouts and recompilations.

The perf comparison below shows some medium-confidence 3-5% improvements on various Speedometer 3 subtests. I'm not sure how accurate this is, but I do expect this to get rid of some bailouts and compilations.

https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=try&newProject=try&newRevision=b55ea1ae7acca29cdfadc2b6d893f4814d597dc3&originalSignature=4586009&newSignature=4586009&framework=13&application=firefox&originalRevision=0555f9e77051726fc84cda22912582175d1b2975&page=1

Attachment #9358099 - Attachment description: Bug 1858679 - Fix perf issue in IRGenerator::emitCalleeGuard for self-hosted lambdas. r?iain! → Bug 1858679 part 1 - Fix perf issue in IRGenerator::emitCalleeGuard for self-hosted lambdas. r?iain!

Searchfox suggested the code to handle self-hosted lazy functions is dead and
this is indeed no longer used to clone lazy self-hosted functions.

Depends on D190821

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d3a7286b836d
part 1 - Fix perf issue in IRGenerator::emitCalleeGuard for self-hosted lambdas. r=iain
https://hg.mozilla.org/integration/autoland/rev/810153993fc0
part 2 - Remove dead code from CloneFunctionReuseScript. r=iain
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: