Vectorize exact MP3 PCM quantization in audio WASM - #270
Merged
Conversation
Hona
force-pushed
the
work/tf2-wasm-simd-performance
branch
from
September 1, 2026 02:26
d4c088e to
d5789ee
Compare
Hona
marked this pull request as ready for review
September 1, 2026 02:27
There was a problem hiding this comment.
🔵 Needs a closer look
It changes correctness-sensitive MP3 PCM quantization and introduces new SIMD/fixture workflows that warrant final human verification despite strong test/evidence additions.
Pull request overview
This PR adds a WebAssembly-SIMD128 vectorized quantization path for MP3 PCM output while preserving exact scalar behavior for the special “first pair” lanes, and wires up build/test/profile infrastructure so SIMD is enabled only for the separately built audio/decoder module (not gameplay).
Changes:
- Vectorize MP3 float→i16 quantization on
wasm32withsimd128, preserving scalar-pair rounding and exact tail handling. - Add an explicit audio WASM Rust-flag path (
-Ctarget-feature=+simd128) distinct from threaded/gameplay flags, plus tests asserting the separation. - Add configured parity evidence generation and a headed Playwright profile (
simd-decoder) for scalar vs SIMD decoder comparison.
File summaries
| File | Description |
|---|---|
| tools/playsrc/tests/tf2-wasm-build.test.ts | Adds coverage ensuring gameplay/threaded flags do not pick up SIMD, and audio flags do. |
| tools/playsrc/tests/simd-configured.test.ts | Adds opt-in configured parity test that produces retained scalar/SIMD WASM artifacts + PCM hashes. |
| tools/playsrc/src/tf2-wasm-build.ts | Factors remap flags and introduces audioWasmRustFlags() to enable SIMD only for audio WASM builds. |
| tools/playsrc/src/profile-runner.ts | Registers a new simd-decoder profile runner entry (with Windows Edge channel override). |
| tools/playsrc/profile/simd-decoder.profile.ts | Adds headed-browser scalar vs SIMD decoder execution + timing/hash evidence capture. |
| tools/playsrc/local-jobs.md | Documents how to prepare and run the new simd-decoder workflow. |
| playwright.simd-profile.config.ts | Adds a dedicated Playwright config for the SIMD decoder profile. |
| packages/presentation/audio/tests/wasm.test.ts | Adds tests for preflight SIMD support checks and “no compile if unsupported” behavior. |
| packages/presentation/audio/src/wasm.ts | Introduces compileAudioModule() which bounds size and rejects unsupported SIMD targets early. |
| packages/presentation/audio/src/playback.ts | Routes audio module compilation through compileAudioModule() to enforce SIMD/capacity checks. |
| packages/formats/mp3/rust/tests/configured.rs | Updates configured test to read pinned local TF2 archive input and retain cow1.mp3 evidence. |
| packages/formats/mp3/rust/src/lib.rs | Reworks decode output fill to a bulk quantize step with a SIMD128 fast-path on wasm. |
| packages/formats/mp3/rust/Cargo.toml | Adds dev-dependencies needed by the configured evidence test. |
| Cargo.lock | Locks new dev-dependency resolution for the mp3 crate. |
Review details
- Files reviewed: 13/14 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3
to
+6
| // (module (func (drop (v128.const i32x4 0 0 0 0)))) | ||
| // Check standard SIMD without validating the complete audio module twice. | ||
| const SIMD128 = new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,23,1,21,0,253,12,...Array(16).fill(0),26,11]) | ||
|
|
Hona
force-pushed
the
work/tf2-wasm-simd-performance
branch
2 times, most recently
from
September 1, 2026 02:47
fc46b5c to
bfe821c
Compare
Hona
force-pushed
the
work/tf2-wasm-simd-performance
branch
from
September 1, 2026 02:55
bfe821c to
98896f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
Headed decoder evidence
This retained screenshot reports 32-call batch means, not individual-call tail percentiles. The profiler now supports individual durations and explicit sample age; no additional results from that instrumentation are claimed here.
Evidence limits
The reported performance evidence is the existing headed x64 PCM/batch measurement; current-main verification uses focused exact-audio and build checks. New individual-call browser tail distributions, ARM headed performance, live-device capture completion and a full 90-second gameplay campaign remain unmeasured. The pending remote task has not been relaunched; its prior unknown outcome/teardown is not treated as successful acceptance.
No graphics, bot work, simulation cadence, networking or production changes. The abandoned live-gameplay profiling extension was removed from this narrow change.