Skip to main content

Module memo

Module memo 

Source
Expand description

The language server’s reusable analysis state (#3243, #1523 S2).

analyse_project_memoised is the entry point the language server calls once per round, passing the same AnalysisMemo each time. The memo keeps each file’s checked output (a FileRecord) keyed by a digest of everything the check read (crate::check_pipeline::file_check_digest); a file whose digest is unchanged is replayed instead of re-checked. The answer must be exactly analyse_project’s; the differential oracle (xtask/tests/analysis_oracle.rs) holds it to that.

bynk check and bynk build never call this: they stay on the plain, table-free path (analyse_project / the driver’s own checks), which is the cold-compile cost R3.15 asks us not to raise. A test pins it.

§The type table’s growth policy

A cached record holds TyIds, so every round of one memo shares one append-only Types table (a TyId stays valid as long as its table does). Interning deduplicates, so an unchanged project adds nothing; but an edit that mints new types leaves the old ones behind. The policy (AnalysisMemo::begin_round): after a round the table’s size is the baseline; once it has grown past GROWTH_FACTOR times that baseline (and past MIN_RESET_LEN, so a tiny project never churns), the memo is dropped and the next round starts cold with a fresh table. That bounds the table to a constant multiple of one round’s, by construction; the oracle’s long edit sequence tests it.

Structs§

AnalysisMemo
State reused between rounds. One per project, owned by the language server.
MemoStats
How a round used the memo, for tests and for the bench’s reporting.

Constants§

GROWTH_FACTOR
The type table may grow to this many times its size after the last cold round before the memo starts over.
MIN_RESET_LEN
…but never resets while smaller than this many entries.

Functions§

analyse_project_memoised
One analysis round over roots, free to reuse what memo learned from the previous round. Must answer exactly what analyse_project answers; the oracle holds it to that.