Skip to content

refactor(analysis): make analysis visitors linear - #134

Merged
zhen8838 merged 6 commits into
tile-ai:mainfrom
zhen8838:refactor/analysis-visitor-families
Aug 29, 2026
Merged

refactor(analysis): make analysis visitors linear#134
zhen8838 merged 6 commits into
tile-ai:mainfrom
zhen8838:refactor/analysis-visitor-families

Conversation

@zhen8838

@zhen8838 zhen8838 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

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

  1. Build Scope ownership and variance tables during the existing normalized walk, using identity-safe integer keys.
  2. Convert compute-cost, memory, roofline, and performance collection to family-owned expression visitors without changing timeline emission order.
  3. Replace the generic validation dispatcher with a performance checker visitor and keep execution-domain validation before analysis.
  4. Fold movement into memory and remove dead structural-occurrence and placement paths.
  5. Store each Op-declared access relation on its Scope, project it for each reader's view, and use boundedness instead of exact cardinality where only countability is required.

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.

@zhen8838
zhen8838 merged commit d73c1ee into tile-ai:main Aug 29, 2026
1 check passed
@zhen8838
zhen8838 deleted the refactor/analysis-visitor-families branch August 29, 2026 04:44
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