Closed Bug 1905716 Opened 4 months ago Closed 4 months ago

Initial support for lazy tiering

Categories

(Core :: JavaScript: WebAssembly, task, P1)

task

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

References

(Blocks 1 open bug)

Details

Attachments

(7 files, 9 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Once bug 1898153 lands, we can build off of it to support lazy tiering. The initial version can be naive, the goal is to only compile a function with Ion after it has triggered some hotness heuristic.

CompileMode currently doubles as both a 'strategy' and 'state' enum.

  • 'strategy' is which overall plan are we following.
  • 'compile once'
  • 'compile with tiering'
  • 'state' tracks where in the plan our module is currently at when
    we're compiling in module generator.
  • 'compile once'
  • 'tiering on first tier'
  • 'tiering on second tier'

With lazy tiering, this setup breaks and it seems cleaner to have two
separate enums to track these independently.

This commit also adds a placeholder mode/strategy for 'lazy' tiering.

Assignee: nobody → rhunt
Status: NEW → ASSIGNED

We currently keep the bytecode alive for debug modules. This changes
this so that we keep it alive for lazy tiering, and moves it to
wasm::Code.

Depends on D215412

To avoid confusion with partial tiering, rename tier specific data to
show if it is only to be used when we're looking for a 'complete' tier
as opposed to a 'partial' tier.

Depends on D215413

With lazy tiering, we can have one code block which contains a function
definition with a direct call to a function definition in a different
code block.

This commit moves CallFarJump out of ModuleGenerator and adds a list of
them to LinkData. When we're compiling a code block, any unresolved call
far jumps are appended to the LinkData. When the code segment is initialized,
the far jumps are applied, initially checking in the shared stubs block only.

Depends on D215414

This introduces per-function hotness counters in baseline. We re-use the
stack overflow check strategy of triggering a trap. We do the hotness
increment in function prologues and loop headers.

Initially the hotness threshold is just '1'. When hotness is reached,
we just reset the hotness to INT32_MAX. A future commit will do something
with this information.

Depends on D215415

Drive-by fix to actually apply the 'await tier2' flag in the JS
shell. We currently only apply it to shell worker contexts and not the
main thread context.

This flag forces tiering to happen for all modules, so it's important
for testing.

Depends on D215416

This commit adds initial support for lazy tiering using a flag
to control it.

In this mode, we compile with baseline then do not trigger a tier2
background compile, but instead wait until a function triggers a
hotness threshold. When a function is hot, we synchronously
compile a tier-2 version of the function and commit it.

Limitations

  • We have to re-enter the function to get into tier-2 code
  • We don't use threads for the tier-2 compile
  • CodeRange.bytecodeOffset is not useable for finding the function definition for
    a function index. This means we have to scan through the whole module to find
    the function definition.
  • Traps are an expensive way to trigger hotness
  • We don't use the unused OS pages (4k) in code pages (64k) for lazy tier2 code.

Depends on D215417

Attachment #9410674 - Attachment description: Bug 1905716 - wasm: Refactor CompileMode into two different enums, add a lazy strategy. r?jseward → Bug 1905716 - wasm: Refactor CompileMode into two different enums, add a lazy mode. r?jseward

Depends on D215418

Depends on D215690

Depends on D215691

Depends on D215692

Not needed now that we have FuncDesc.

Depends on D215693

Depends on D215695

Depends on D215696

Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/0f75f3a3e577 wasm: Refactor CompileMode into two different enums, add a lazy mode. r=jseward https://hg.mozilla.org/integration/autoland/rev/a570798a633a wasm: Keep bytecode alive for lazy tiering. r=jseward https://hg.mozilla.org/integration/autoland/rev/ef03ce2768ab wasm: Rename all tier data on Code to be 'complete'. r=jseward https://hg.mozilla.org/integration/autoland/rev/3f12d09cd5ae wasm: Allow linking CallFarJumps between code blocks. r=jseward https://hg.mozilla.org/integration/autoland/rev/8978a8942fd9 wasm: Introduce hotness counters in baseline when lazy tiering. r=jseward https://hg.mozilla.org/integration/autoland/rev/2aeac4710f81 wasm: Use await tier2 flag in JS shell. r=jseward https://hg.mozilla.org/integration/autoland/rev/426ef07e0ed2 wasm: Initial support for lazy tiering. r=jseward https://hg.mozilla.org/integration/autoland/rev/9b917c65a1a7 apply code formatting via Lando
Severity: -- → N/A
Priority: -- → P1
Depends on: 1907151

Comment on attachment 9411133 [details]
WIP: Bug 1905716 - wasm: Move FeatureUsage onto ModuleMetadata.

Revision D215690 was moved to bug 1907151. Setting attachment 9411133 [details] to obsolete.

Attachment #9411133 - Attachment is obsolete: true

Comment on attachment 9411134 [details]
WIP: Bug 1905716 - wasm: ModuleMetadata strongly owns CodeMetadata.

Revision D215691 was moved to bug 1907151. Setting attachment 9411134 [details] to obsolete.

Attachment #9411134 - Attachment is obsolete: true

Comment on attachment 9411135 [details]
WIP: Bug 1905716 - Drop FuncType* from FuncDesc to make it POD.

Revision D215692 was moved to bug 1907151. Setting attachment 9411135 [details] to obsolete.

Attachment #9411135 - Attachment is obsolete: true

Comment on attachment 9411136 [details]
WIP: Bug 1905716 - wasm: Serialize FuncDesc, replace ad-hoc old users.

Revision D215693 was moved to bug 1907151. Setting attachment 9411136 [details] to obsolete.

Attachment #9411136 - Attachment is obsolete: true

Comment on attachment 9411138 [details]
WIP: Bug 1905716 - wasm: Remove typeIndex from FuncImport and FuncExport.

Revision D215694 was moved to bug 1907151. Setting attachment 9411138 [details] to obsolete.

Attachment #9411138 - Attachment is obsolete: true

Comment on attachment 9411139 [details]
WIP: Bug 1905716 - wasm: Remove last mutation of CodeMetadata from ModuleGenerator.

Revision D215695 was moved to bug 1907151. Setting attachment 9411139 [details] to obsolete.

Attachment #9411139 - Attachment is obsolete: true

Comment on attachment 9411140 [details]
WIP: Bug 1905716 - wasm: Don't recreate ModuleMetadata for tier2.

Revision D215696 was moved to bug 1907151. Setting attachment 9411140 [details] to obsolete.

Attachment #9411140 - Attachment is obsolete: true

Comment on attachment 9411141 [details]
WIP: Bug 1905716 - wasm: Remove CompileArgs from ModuleGenerator constructor.

Revision D215697 was moved to bug 1907151. Setting attachment 9411141 [details] to obsolete.

Attachment #9411141 - Attachment is obsolete: true

Comment on attachment 9411142 [details]
WIP: Bug 1905716 - wasm: Only decode the function that is being re-compiled for tier2.

Revision D215698 was moved to bug 1907151. Setting attachment 9411142 [details] to obsolete.

Attachment #9411142 - Attachment is obsolete: true
Blocks: 1907151
No longer depends on: 1907151
Regressions: 1907477
Regressions: 1909897
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: