refactor(analysis): make analysis visitors linear - #134
Merged
zhen8838 merged 6 commits intoAug 29, 2026
Conversation
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.
Why
After #126 merged, dedicated CI grew from 325.64s to 621.75s while adding only four tests. Two analysis paths had become quadratic at model scale: every Call searched the complete Scope tree for its owner, and variance/access relations repeatedly rebuilt shared expression DAG work. This PR restores one-build ownership and traversal while preserving reports byte-for-byte.
What
The deterministic hotspot ledger is: count_val 8,818 -> 3,944; _held_countable 3,986 -> 0; analysis relation rebuilding 1,160 -> 202, comprising 190 primary builds and 12 documented cross-scope fallbacks.
Contract
relations_of now returns the Op-declared, level-independent AccessRelations; local_relations_of returns those relations projected into the caller's type view. This is an intentional semantic name swap across all callers. Analyzer.input_checker is replaced by Analyzer.get_checker(); analyzers without a checker return None. Analysis metadata and rendered reports remain unchanged.
Risk
Scope.one_pass still accounts for 3,056 count_val calls and is intentionally outside this plan. Loop-footprint fallback labels and ordering remain process-identity based; their cross-process nondeterminism is tracked separately in #133 and is not changed here. Validation includes four raw report comparisons, 925 passed plus 4 skipped in the full suite, 156 installed-wheel tests, and identical JUnit test-name sets against the pre-refactor baseline. Dedicated CI passed in 456.00s, down 26.7% from #126's 621.75s but still 40.0% above main's 325.64s; the remaining gap is not hidden by the local host's unrelated compiler load.