ruff
ba777a80 - [ty] Cache non-terminal-call reachability prefixes (#26810)

Commit
89 days ago
[ty] Cache non-terminal-call reachability prefixes (#26810) ## Summary Statement-level call predicates are assigned in source order but appear in reverse order in reachability decision diagrams. We warm preceding calls in source order to avoid a deeply recursive Salsa query chain, but the existing implementation rescans the entire predicate prefix for every later expression-inference query. With `n` statement calls, the query for call `i` scans the first `i` predicates, producing `1 + 2 + ... + n = O(n²)` total scanning even though the individual call analyses are cached. This change indexes statement-call predicates once for scopes with more than 16 calls and decomposes each requested prefix into reusable power-of-two ranges. Each leaf analyzes 16 actual calls iteratively, while smaller scopes retain the direct path without allocating the tracked index. This revisits the approach from #26763, using call-based rather than raw-predicate-based chunks so the cached work remains proportional to the expensive predicates. This is the first of three related PRs. [#26811](https://github.com/astral-sh/ruff/pull/26811) caches sparse reachability checkpoints, and [#26793](https://github.com/astral-sh/ruff/pull/26793) defers statement-call narrowing gates.
Author
Parents
Loading