Repository navigation
fix(standalone): compile retained WebAssembly assets for AOT - #182304
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds compile-time imports for retained WebAssembly assets in experimental AOT standalone builds while preserving existing library loaders. Example: Encode and decode 100 Opus frames in the supplied macOS arm64 dependency benchmark.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it provides a useful, maintainer-directed AOT performance improvement that current main lacks, with no concrete introduced defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe standalone builder consumes a completed runtime build and its sidecar resource plan, then produces an executable, companion runtime directory, and packaging manifest. flowchart TD
A[Completed runtime build] --> B[Plugin selection and resource plan]
B --> C[AOT WASM import generation]
C --> D[Bun executable compilation]
B --> E[Retained sidecar bytes]
D --> F[Library and worker workloads]
E --> F
Technical reviewBest possible solution: Use the existing sidecar plan to supply byte-identical WASM compiler inputs without introducing a competing runtime loader. Do we have a high-confidence way to reproduce the issue? Current main lacks static registration, and the benchmark compiler's documented contract explains why dynamically loaded modules use the interpreter; the author supplies comparative dependency results, but this review ran no target code. Is this the best way to solve the issue? The change addresses the compiler boundary directly, retains sidecar ownership and lazy loading, and avoids runtime patches or duplicate asset-selection state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6ba8529d86d3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +158, Docs +26, Other +463. Total +647 across 5 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 2:43 AM ET / 06:43 UTC. |
|
Merged via squash.
|
What Problem This Solves
Fixes slow image, PDF, voice, command parsing, Code Mode, Matrix crypto, and archive operations in experimental AOT standalone builds.
User Impact
Retained WebAssembly workloads can use compiled native code in AOT artifacts. Standard JIT and bytecode builds keep their existing packaging. AOT executables grow to hold the compiled code; the sidecar still supplies the bytes consumed by each library's existing lazy loader.
Why This Change Was Made
The existing sidecar resource plan already owns which assets survive plugin selection. The final compiler now receives literal
.wasmimports from that plan, deduplicated by byte identity. QuickJS'sencoding.sois registered as WASM, and Opus's current inline payload is decoded at build time under an explicit decoder contract. Libraries keep their existing initialization and resource loading. The manifest records source paths, SHA-256, and sizes for the included modules. Content-addressed registration imports also carry every WASM byte change into the shared module-graph fingerprint used by matched AOT/JIT support artifacts. All new state stays in builder scratch; there is no runtime registry.Evidence
node scripts/bench-standalone-wasm.mjs "$AOT_BUN" ./wasm-probecompiles small dependency probes only. All eight workloads matched across JIT, JIT with registration, dynamic-WASM AOT, and static-WASM AOT. Checks cover full PCM/image/PDF text and RGBA/tree-expression/TAR-manifest hashes, plaintext crypto roundtrips, and numeric guest results. QuickJS and encoding modules transfer to a real worker that closes naturally. Hashing runs outside the measured interval. Every WASM asset was byte-verified against the current frozen workspace install.Five fresh-process samples per mode, interleaved; batch timing follows two workload warmups. macOS arm64, Bun AOT toolchain
1.4.4-canary.1+5d8fe974f, identical dependency bytes throughout. Times are milliseconds. This was a busy shared host (load averages 45.75/46.14/51.26), so these library batches are the scope of the performance result.Compiled WASM increases executable size; these separate probe binaries include that machine code and retain library input bytes. Full standalone release qualification is outside this focused evidence; no whole-application AOT build was run.
Focused checks passed:
pnpm test test/scripts/bun-standalone-wasm.test.ts test/scripts/bun-standalone-support.test.ts test/scripts/bun-standalone-contract.test.ts --maxWorkers=1(32 tests; 4.10 s wall), targeted script/test lint, scoped formatting, the three tests' type project, and the tooling test typecheck leaf. The new fingerprint regression failed with the original fixed registration path and passed with content-addressed imports. The combined pre-fix replay also exposed a missing dependency in the support test fixture (2 failed, 6 passed; 7.41 s wall), corrected on main separately. Independent Codex review is scoped-clean through P2 with no remaining findings.