Skip to content

refactor(compile): drop fine-grained edit reuse in favour of coarse caches - #1030

Merged
kvlonge merged 5 commits into
mainfrom
refactor/simplify-compile-caches
Oct 8, 2026
Merged

kvlonge merged 5 commits into
mainfrom
refactor/simplify-compile-caches

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

Compile caching grew fine-grained edit-reuse layers that are hard to keep correct. We keep a few coarse, content-addressed caches, each checked by edit sequences against --no-cache, until the native compiler lands.

Changes

Cache inventory:

  • Kept: whole-project no-change reuse (project-reuse-v1); analysis cache; macro-call store; rules caches.
  • New: sql-test-scans.bin, a kind of the shared native store. One whole entry per SQL test file (expanded CTEs, expected models), keyed by file text, lexical rules, installed and native code identity, and scan version. Failed scans are not stored.
  • Removed: render reuse, the discovery, analysis and write reuse built on it, and the fact cache. Their leftover facts-v1/ folders and .render files are deleted.
  • Unchanged: reference, scope-index and SQL-test artifact caches.

Also:

  • Custom rules: the cache already reruns only changed subjects. The slowdown was its code digest, which the fact cache used to compute early; in the rules worker it waited on the GIL. It is now computed before the worker starts, and the compiler frontier owns it.
  • Native store open and save are shared by both store kinds.
  • Docs: an edited model recompiles uncached until the native compiler ships; the scan cache is documented.
  • Perf guards: --edit-max-ratio for the same-runner edit mode only, 1.25 (dense) and 1.20 (fresh), above the observed 1.18 and 1.14, until native rendering is the default. Other limits unchanged.

Verification

  • Edit-sequence oracle: test, model and adapter edits; lexical rules, native build, Python code, corrupted file and entries; a sabotaged scan key is caught
  • Retired cache files are deleted by cached compiles only
  • One-model custom-rule edit reruns one subject and matches --no-cache
  • cargo test --workspace --all-features, clippy on 1.99.0
  • make compiler-differential (CI flags), -shipped, tests/e2e/scripts/compiler_differential
  • make check-ci, make test, hygiene scan

@kvlonge
kvlonge force-pushed the refactor/simplify-compile-caches branch 2 times, most recently from 3ba65d8 to 6505ae3 Compare October 8, 2026 15:11
…aches

Remove render reuse after model-only edits, the discovery, analysis and
artifact-write reuse built on it, and the per-file compile fact cache.
Every edit now compiles the whole project; whole-project no-change reuse,
the analysis cache, the macro-call store and the rules caches remain.

The expanded SQL-test extraction and expected-model scans run uncached;
both are lexical native scans. Rule caches take the code identity from the
rule engine. The edit-sequence oracle covers the remaining caches,
including sequences that advance the analysis cache between compiles and
sabotaged invalidation that the oracle must detect.
Store whole per-file expanded SQL-test CTE extraction and expected-model
scans as a new kind of the shared native store, keyed by the scanned text,
adapter lexical rules, native build and scan version. Failed scans are not
stored and damaged or foreign entries are rescanned.

Digest installed code before the custom-rules worker starts so its file
walk no longer waits on the GIL beside built-in rules.

Give the same-runner one-model edit mode its own ratio limit until native
rendering is the default.
… cache files

Stored expected-model names can come from the Python extractor, so the
scan store environment now includes the installed code identity, which
moves from the rule engine to the compiler frontier for both to share.

Opening the compiler cache root deletes every engine's retired fact cache,
and storing a reuse entry deletes render files older releases left in the
store directory.
@kvlonge
kvlonge force-pushed the refactor/simplify-compile-caches branch from 9add490 to 5c7abf2 Compare October 8, 2026 16:46
@kvlonge
kvlonge enabled auto-merge (squash) October 8, 2026 16:46
@kvlonge
kvlonge merged commit 450b807 into main Oct 8, 2026
40 of 41 checks passed
@kvlonge
kvlonge deleted the refactor/simplify-compile-caches branch October 8, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant