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§
- Analysis
Memo - State reused between rounds. One per project, owned by the language server.
- Memo
Stats - 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 whatmemolearned from the previous round. Must answer exactly whatanalyse_projectanswers; the oracle holds it to that.