Implement startup batching: 12x faster boot

Batch-compile all ~64 IR primitives into a single WASM module at startup.
Replaces 64 separate Module::new + Instance::new with 1 of each.
Reuses compile_consolidated_module() directly, removed compile_core_module() stub.

Boot time: 7.7ms -> 0.6ms (release), test suite: 5.1s -> 1.5s (debug).
13 of 14 optimizations now implemented. 392 tests passing.
This commit is contained in:
2026-04-02 13:05:53 +02:00
parent 8c53afa28a
commit f7a8bf1d24
3 changed files with 72 additions and 22 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ This document describes every optimization that makes sense for WAFER, why it ma
| 10 | Codegen Improvements | Codegen | Done | Medium |
| 11 | wasmtime Configuration | Runtime | Done | Low |
| 12 | Dictionary Hash Index | Runtime | Done | Low |
| 13 | Startup Batching | Architecture | Not started | Low |
| 13 | Startup Batching | Architecture | Done | Low |
| 14 | Float / Double-Cell | Codegen | Not started | Future |
## 1. Stack-to-Local Promotion
@@ -422,7 +422,7 @@ This affects **compile time** (word lookup during parsing), not runtime (compile
## 13. Startup Batching
**Status: Not started.** `compile_core_module()` stub exists in `codegen.rs`.
**Status: Done.** All IR primitives batch-compiled into a single WASM module at boot via `compile_consolidated_module()`. Reduces boot from ~7.7ms to ~0.6ms (12x faster). The `compile_core_module()` stub has been removed.
Currently, each of the 80+ primitives registered at boot creates a separate WASM module: `wasm-encoder` builds it, `wasmparser` validates it, Cranelift compiles it, and wasmtime instantiates it. This happens 80+ times sequentially.