Closed Bug 1811024 Opened 1 year ago Closed 1 year ago

wasm-baseline: speed up creation of stack maps

Categories

(Core :: JavaScript: WebAssembly, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: jseward, Assigned: jseward)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The wasm baseline compiler slows down significantly when compiling code that
has extensive need of stack maps, for example the Dart-Barista benchmark.
This is because StackMapGenerator::createStackMap spends a lot of time
iterating over a vector of booleans, one element at a time, to identify
reftyped stack slots. It is bad: for this example,

   wasm::BaselineCompileFunctions          costs 1175 million insns
of which StackMapGenerator::createStackMap is     701 million insns

That vector is sparsely populated -- for Dart-Barista overall, 1.1% of entries
are true, and for most functions that number is 0.2% or less. Hence it
would be of benefit to be able to skip long runs of false entries quickly.

The wasm baseline compiler slows down significantly when compiling code that
has extensive need of stack maps, for example the Dart-Barista benchmark.
This is because StackMapGenerator::createStackMap spends a lot of time
iterating over a vector of booleans, one element at a time, to identify
reftyped stack slots.

This patch gives class MachineStackTracker its own iterator class Iter to
hide the details. This provides fast(er) iteration by scanning backwards
through the vector of booleans until the scan-index becomes 8-aligned. After
that, it jumps backwards in steps of 8 elements to the extent possible.

For a --no-threads --wasm-compiler=baseline compilation only of Barista 3,
this reduces compilation time from 0.110 to 0.082 user seconds (Intel Core i5
1135G7).

Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0e4975937eac
wasm-baseline: speed up creation of stack maps.  r=rhunt.
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: