Skip to content

perf(compile): reuse unaffected model renders after model-only edits - #955

Merged
kvlonge merged 4 commits into
mainfrom
perf/incremental-edit-compile
Oct 5, 2026
Merged

kvlonge merged 4 commits into
mainfrom
perf/incremental-edit-compile

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Why

Editing one model recompiled every model from scratch. Compile reuse (#951) only helps when nothing changed. This change reuses unaffected renders after model-only edits, with output byte-identical to --no-cache.

Changes

Invalidation by input kind (change set C comes from stored file stamps and digests; invocation, runtime, env, settings and modules must be unchanged):

  • Edits to existing model files only (C within the stored model paths, model path list identical): the edited models are rendered again; all others reuse the stored render, and its diagnostics and env reads are replayed. Renders that read run.id or provider settings are never stored.
  • Shape propagation, semantics, contracts, built-in and custom rules, and artifacts run on full inputs through their existing per-key caches.
  • Sources, tests, scenarios, singular audits, and source/seed audits are reused as whole groups. A model's attached audits are reused only with that model's render.
  • Added, removed or renamed models, and macros, imported modules, config, path_defaults, declarations, scopes, seeds, sources, tests or audits: full render.

Storage: renders are stored only when a compile entry already exists, so cold compiles pay nothing. Files are a zlib-compressed base plus a bounded overlay, two newest kept, verified on read; any fault means a full render. Stored bytes are released once renders are decoded.

Verification

  • Real-CLI DuckDB oracle: authored edit sequences plus seeded random chains, each step byte-compared with --no-cache; fails when change detection is broken. Save-policy test: cold stores no renders, the next miss does.
  • One independent review plus follow-up; make test, make check-ci.
  • Medians of 3 alternating runs at load < 3, dense 3k / 10k: cold 16.2 / 49.6 s, unchanged. First edit after cold +0.7 / +2.3 s. Later edits 8.6 → 7.6 s and 27.0 → 23.7 s, with peak RSS +0.1 / +0.35 GB. Render store 5 / 18 MB.

…ers off the critical path

Reuse per-model attached audits and whole audit groups after model-only edits, store renders as a base file plus a bounded overlay, pickle new renders on a background thread, keep GC paused across compile and store, and resolve lint project files once per parent directory.
…nd release them once decoded

Serialize renders at store time instead of on a background thread, which contended for the GIL with analysis. Skip render storage on cold compiles, compress render files with zlib, release stored render bytes after rendering, and announce slow render loading and recording. Carry forward stored module stamps whenever a render is reused, so outside modules imported only while rendering stay tracked.
@kvlonge
kvlonge enabled auto-merge (squash) October 5, 2026 21:54
@kvlonge
kvlonge merged commit d576523 into main Oct 5, 2026
32 checks passed
@kvlonge
kvlonge deleted the perf/incremental-edit-compile branch October 5, 2026 22:20
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