Repository navigation
fix(builder): check each builder once per up_to_date call - #429
Merged
Merged
Conversation
A feature depends on the builders of its faults, and a fault frame on the builders of the faults that cut it. BaseBuilder.up_to_date recursed into every fault builder, and each fault frame into its three coordinate builders, with no memory of what was already checked, so one check walked every path through that graph (x3 at each fault frame). It runs at the start of every evaluation. In a network of cutting faults this dominated: building one fault of a 94-fault model made 36 million up_to_date calls (and as many logger.info calls) for 652 fault applications. The outermost call now keeps the set of builders it has checked (in a context variable), and a builder already in it returns at once. The recursion still brings the faults up to date before the builder itself, so a skipped builder is already up to date. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose
added a commit
that referenced
this pull request
Nov 26, 2026
…o feat/003-fault-evaluation-performance The branch already had the same fixes as merges of their PR branches. Two conflicts: _fault_segment.py keeps the branch's placement of the #425 fallback (after the frame gradient of _evaluate_frame), and test_cut_fault_step_direction.py keeps the branch's version that turns the shared frame lookup off for the NaN-rule test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every evaluation starts with
builder.up_to_date().BaseBuilder.up_to_daterecursed into the builder of every fault of the feature, andFaultBuilder.up_to_dateinto its three coordinate builders, each of which recursed into the faults that cut the frame — with no memory of what was already checked. One check therefore walked every path through the graph of faults (×3 at each fault frame).In a network of cutting faults this dominated the build: building one fault of a 94-fault test model (14 faults in its chain of cutting faults) made 36 million
up_to_datecalls (and as manylogger.infocalls) for 652 fault applications, 45 of the 51 s.Fix
The outermost
up_to_datecall keeps the set of builders it has checked (in a context variable, so nested calls share it and threads do not), and a builder already in the set returns at once. The recursion still brings the faults of a builder up to date before the builder itself, so a skipped builder is already up to date. The fault and frame builders only delegate to their coordinate builders, so they need no change; no signature changes.Results
Tests
tests/unit/modelling/test_builder_up_to_date_once.py: in a small graph of cutting faults each interpolator is checked once per call (up to 16 times before the fix); a fault marked stale is still rebuilt.pytest tests: 2913 passed, 31 skipped. Ruff: no new findings.🤖 Generated with Claude Code
https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx