Expand description
A content-hash-keyed cache of compiled wasmtime::Modules.
wasmtime::Module::new measurably costs ~1.5s for a ~3.3MB module (the
shared Rhai interpreter this feature adds) vs. ~125ms for a small
example block — over 10x — and today nothing in this codebase caches a
compiled module at all: Guest::new recompiles from scratch on every
single job run. Every Script-kind node, across every spec and every
job ever run against it, shares byte-identical module_bytes (the one
embedded interpreter), so this cache turns an otherwise-repeated ~1.5s
tax into a one-time cost per process lifetime.
Structs§
- Module
Cache - Load-bearing invariant this cache does not check: every
compilecall through oneModuleCachemust pass the samewasmtime::Engineevery time. AModuleis only valid for theEnginethat compiled it — mixing engines through one cache would silently return aModulecompiled for the wrongEngine. This codebase constructs exactly oneEngineper process (cuttlefishd’s andcuttlefish build’smain), so aModuleCacheconstructed once alongside it, and never shared across processes, upholds this automatically. A test that constructs its own throwawayEngineshould also construct its own throwawayModuleCache— never reuse one across two differentEngines.