Skip to content

perf: borrow instruction stream across unbudgeted tail dispatch - #64

Open
matthargett wants to merge 1 commit into
explodingcamera:nextfrom
rebeckerspecialties:perf/borrow-instruction-stream
Open

matthargett wants to merge 1 commit into
explodingcamera:nextfrom
rebeckerspecialties:perf/borrow-instruction-stream

Conversation

@matthargett

@matthargett matthargett commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Draft: standalone tail-dispatch change on next. This PR no longer depends on the closed #63.

Unbudgeted tail dispatch borrows the current function's instruction slice across opcode handlers and retains its Shared<WasmFunction> owner. It rebinds only after a function switch. Fuel/time-budgeted dispatch is unchanged, and no unsafe code is added. A focused test covers linked modules, a host import, indirect calls, returns, and fuel suspension.

Measured against current next (693d590) on the efficiency cores of an iPhone 12 (A14), iPhone XS Max (A12) and iPhone SE (A13); each cell is the change in cycles per call, median of five interleaved launches per build:

benchmark A14 A12 A13
xmrsplayer (1024-frame buffer) −6.0% −11.4% −9.0%
audio DSP (1000 frames × 512) −8.9% −15.1% −13.7%
graphql-validation (AS) −7.3% −9.9% −8.0%
multi-memory twin: one memory −7.0% −11.4% −11.3%
crc32 (64 KB) −13.5% −20.9% −15.6%
convolution 256×256 −12.6% −14.0% −12.3%
sieve (10000) −11.9% −14.2% −12.8%
bulk_memory (memory.copy/fill) −8.6% −13.5% −13.4%
matmul relaxed-simd FMA −5.9% −13.1% −11.6%
GC binary trees (~130K struct.new) −2.5% −1.8% −2.8%
fib(30) −6.1% −12.1% −11.6%
tail-call FSM (65536 return_call) −3.2% −1.4% −5.6%
call_indirect (200K) −2.5% +3.8% −1.3%
call_ref (200K) +0.4% +6.2% −1.4%
vtable_poly4 (200K) +1.1% +5.2% −1.0%
EH parser, exnref (4096 stmts, 25% throw) +4.4% +12.5% +2.9%
geomean, cycles −5.7% −7.4% −8.2%
geomean, instructions −1.9% −2.2% −2.0%
geomean, wall time −5.9% −9.9% −8.3%

note that the call_indirect benchmark regression on A12 (iPhone XS) is something I've seen before with wasmtime/WAMR benchmarking+optimization, and it's due to the efficiency cores on that silicon having much weaker branch prediction. it ended up being a "nice to have" once the relaxed simd128 lowering was optimized, though: under WAMR, xmrsplayer as WASM bundle was able to play a 16-track ScreamTracker3 module without sound skips or thermal throttling. so, in the words of The Guide, Don't Panic :D

@matthargett
matthargett force-pushed the perf/borrow-instruction-stream branch from b6df12d to 50f7340 Compare September 25, 2026 04:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant