[ty] Cache reachability evaluations during inference#25696
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.36%. The percentage of expected errors that received a diagnostic held steady at 88.82%. The number of fully passing files held steady at 93/134. |
Memory usage reportMemory usage unchanged ✅ |
|
Merging this PR will improve performance by 4.29%
Performance Changes
Tip Curious why this is faster? Use the CodSpeed MCP and ask your agent. Comparing Footnotes
|
7d9ae1a to
e8116b7
Compare
|
(Sorry, couldn't get to this today, will be looking at this first thing tomorrow.) |
|
It's not urgent, feel free to prioritize other work above it. I appreciate the comment though! |
dhruvmanila
left a comment
There was a problem hiding this comment.
This looks reasonable (sorry for the wait).
I had some help with Codex to try to understand everything that's happening here with regards to the cache, why it's beneficial and I think I have a hang of it.
Regardless, I think it might be useful to add some documentation around the new ReachabilityEvaluationCache and it's methods.
This reverts commit 6e60d3d.
e8116b7 to
6810e53
Compare
Summary
Place lookup repeatedly evaluates the same reachability constraints while inferring a region. Each evaluation walks the ternary decision diagram and may infer predicate truthiness again, even when an earlier binding or declaration lookup already evaluated the same node.
This change adds an inference-local reachability evaluation cache. The builder's primary reachability graph uses a dense vector indexed directly by
ScopedReachabilityConstraintId; constraints from other use-def maps use a hash map keyed by graph identity and node ID. Including graph identity is necessary because distinct reachability graphs can reuse the same local node index and can contain predicates from the same scope. Speculative builders share the cache with their parent builder.In reality, the impact here seems to be quite varied by project... But the benchmarks are positive.