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, so a source or format change misses cleanly instead of loading stale bytecode.

Functions§

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
Store prog (compiled from src) into the shard, replacing any prior entry.