Closed Bug 1839078 Opened 2 years ago Closed 2 years ago

IonCompileScriptForBaselineOSR called 658910 times for generator function in PerfDashboard benchmark

Categories

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

defect

Tracking

()

RESOLVED FIXED
117 Branch
Tracking Status
firefox117 --- fixed

People

(Reporter: jrmuizel, Assigned: mgaudet)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(2 files)

We spend 10x as much time as Chrome in the following function:

*[Symbol.iterator]() {
    const data = this._data;
    const afterEnd = this._afterEndingIndex;
    let i = this._startingIndex;
    for (let i = this._startingIndex; i < afterEnd; ++i)
        yield data[i];
}

The bulk of that time is in js::jit::IonCompileScriptForBaselineOSR which we call 658910 times. This seems suspiciously high to me.

Firefox: https://share.firefox.dev/42LDCh5
Chrome: https://share.firefox.dev/3CDjEux

If we can get to Chrome speed we'll improve our score on this benchmark by 6.4%

Blocks: speedometer3
Whiteboard: [sp3]

IonCompileScriptForBaselineOSR is successful, so we enter Ion code via OSR but we then yield immediately to the caller.

We can only resume generator code in Baseline, so we're stuck in a cycle of resume generator in Baseline => OSR to Ion code => yield immediately. We spend so little time in Ion code that the overhead from OSR is much worse than just running it in Baseline.

Depends on: 1681338

Short-term we probably need some heuristic to not enter Ion for generators via OSR in this case.

Longer-term we should redo our implementation to support resuming in Ion code. Other engines transform generators to look more like a normal function with a switch-statement to make JIT support easier.

Severity: -- → S3
Priority: -- → P1
Priority: P1 → P2

Local testing of the simplest "Hey, what if we don't warp compile yield in a loop" patch speeds Markus' shell testcase up by 50%.

The general thrust of this heuristic is that we allow yield to be Ion compiled under two
circumstances:

  1. There is is sufficient bytecode that we believe it may be profitable to Ion compile
  2. There is an inner loop without a yield that suggests there will be enough work to avoid
    OSR overhead.

This patch tested on SP3 improved the PerfDashboard subtests by ~4%.

Assignee: nobody → mgaudet
Status: NEW → ASSIGNED
Pushed by mgaudet@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c45e12588c5b Add a loop-analysis heuristic for Warp compiled generators r=jandem
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 117 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: