Skip to content

perf(compile): delta-compile dynamic columns, audit factories and model rules - #1201

Merged
kvlonge merged 7 commits into
mainfrom
perf/delta-compile-real-project-shapes
Oct 21, 2026
Merged

kvlonge merged 7 commits into
mainfrom
perf/delta-compile-real-project-shapes

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Why

On a large project, every edit compiled in full. The fallback message blamed the invocation or environment, but that came from turning on SQLBUILD_VERIFY_DELTA_COMPILE itself. Three project shapes ruled delta compiles out: a model with dynamic_columns, audit factories attached by unchanged models, and model-subject custom rules that had to run again for the edited model.

Changes

  • Name the identity component that changed when a delta compile falls back. SQLBUILD_VERIFY_DELTA_COMPILE no longer invalidates a stored compile.
  • The project image keeps the dynamic column families. A delta injects them for models it does not analyse and falls back if an edit changes a model's own families.
  • The image keeps each model's attached audit factories, so a delta stops reporting factories attached elsewhere as orphaned.
  • A delta runs model-subject custom rules for its own models when their recorded reads are limited to those models' SQL, columns, contract and grain, project files, and the source list. Read sets are checked against the stored rule cache before the delta starts and again after the rules run. Any other read falls back.
  • A custom rule's tree.resources_under read (listed from the project's models, which a delta holds only partly) makes the delta fall back.
  • Image format v9. Compile docs updated.

Verification

  • New E2E cases in test_compile_delta.py: dynamic columns, an audit factory, a per-model rule, all shapes together under SQLBUILD_VERIFY_DELTA_COMPILE=1, and fallback messages for a families edit and for a new tracked variable. All 24 delta tests pass.
  • Rust unit tests: image round trip with families and audit references, plus delta-safe fact keys.
  • clippy -D warnings, fensu, ruff.
  • On a private project with about 2,200 models, a one-model edit went from about 7.7 s CPU (full) to about 1.9 s (delta).

…entity

Delta compile reported one message for any invocation, runtime, search
path, environment, settings or module change. Name the first component
that differs instead.

SQLBUILD_VERIFY_DELTA_COMPILE was a tracked variable, so turning it on
for one compile changed the reuse identity and made the very edit it
was meant to verify fall back. It does not change compile output, so it
no longer invalidates a stored compile.
…tories and model rules

Three project shapes made every edit compile in full:

- Any enforced model declaring dynamic_columns ruled out the project
  image. The image now keeps the analysis request's families and a
  delta injects them for models it does not analyse; an edit that
  changes a model's own families still falls back.
- A delta saw only the rerun models' headers, so every audit factory
  attached elsewhere was reported as orphaned and the delta fell back.
  The image keeps each model's attached factories.
- Any custom rule that had to run again ruled out the delta, so editing
  a model a model-subject rule reads always compiled in full. A delta
  now runs model-subject rules for its own models when their recorded
  reads are limited to those models' SQL, columns and contract, project
  files, and the source list (kept in full when a rule reads it). It
  checks the stored read sets before starting and the new ones after,
  and falls back otherwise.

The image format moves to v9.
… a folder

tree.resources_under is listed from the project's models, not the
filesystem, and a delta compile holds only the models it reruns. A
model-subject rule reading it for an edited model ran on the partial
list and could report different findings than a full compile. Treat it
as a read beyond the changed models so the delta falls back.
@kvlonge
kvlonge enabled auto-merge (squash) October 21, 2026 16:45
@kvlonge
kvlonge merged commit b5bdb76 into main Oct 21, 2026
46 checks passed
@kvlonge
kvlonge deleted the perf/delta-compile-real-project-shapes branch October 21, 2026 20:58
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