Skip to main content

Module cache

Module cache 

Source
Expand description

rkyv-backed bytecode cache for compiled JS scripts (mirrors the fleet’s pythonrs/zshrs/rubylang design). Every ordinary node foo.js run is transparently cached: the source is hashed, the shard consulted, and on a hit the compiled fusevm::Chunks run directly — lex/parse/lower are skipped entirely. On a miss the program is compiled, stored, then run. node --build warms the same shard ahead of time.

Layout: a single shard at ~/.node-js/scripts.rkyv. The outer container is a zero-copy rkyv archive (Shard), validated on load; each inner entry blob is a bincode-encoded CProg (the compiled fusevm::Chunks + func/try tables), because fusevm::Chunk is serde-owned, not rkyv::Archive. The key is a 64-bit hash of the source plus a schema version, the release version and an identity for the running BINARY, so a source, format, release or codegen change misses cleanly instead of loading stale bytecode.

Functions§

flush
Write the resident shard back, once, at the end of the run.
key_for
A stable content key for a source string (fast FxHash, used for lookup).
load
Look up a compiled program for src, if present and current.
store
Record prog (compiled from src) in the resident shard. Reaches disk at flush, not here.