Skip to main content

Module module_source

Module module_source 

Source
Expand description

Process-wide owner of module source bytes and everything derived from them.

One spawn of a large pipeline visits every file in the transitive import graph at least twice: once while folding the entry chunk’s cache key, and again while the VM actually loads each module. Every one of those sites needs the same three facts — the text, its content digests, and its import list — and each used to derive them independently, so a single module source was read from disk twice, held in memory three times, and hashed three times per process.

ModuleSource owns those bytes and derives each fact at most once. Instances are memoized by the file’s stat identity (len, mtime_ns), so an on-disk edit yields a fresh entry and a stale one is never reused: a long-lived worker still observes edited pipelines exactly as a cold process would. The derived bytes are identical to what independent derivation produced, so cache keys are unchanged.

Structs§

ModuleSource
One module’s source text plus the facts callers derive from it.