Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Cache reachability evaluations during inference#25696

Merged
charliermarsh merged 7 commits into
mainfrom
codex/ty-reachability-cache
Jun 11, 2026
Merged

[ty] Cache reachability evaluations during inference#25696
charliermarsh merged 7 commits into
mainfrom
codex/ty-reachability-cache

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 6, 2026

Copy link
Copy Markdown
Member

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.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 6, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The 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.

@astral-sh-bot

astral-sh-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@codspeed-hq

codspeed-hq Bot commented Jun 6, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.29%

⚡ 1 improved benchmark
✅ 66 untouched benchmarks
⏩ 60 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime sympy 80.2 s 76.9 s +4.29%

Tip

Curious why this is faster? Use the CodSpeed MCP and ask your agent.


Comparing codex/ty-reachability-cache (63eaa1f) with main (b708d72)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@charliermarsh charliermarsh marked this pull request as ready for review June 6, 2026 03:45
@astral-sh-bot astral-sh-bot Bot requested a review from dhruvmanila June 6, 2026 03:45
@charliermarsh charliermarsh marked this pull request as draft June 6, 2026 03:48
@charliermarsh charliermarsh marked this pull request as ready for review June 6, 2026 04:06
@charliermarsh charliermarsh added the performance Potential performance improvement label Jun 6, 2026
@charliermarsh charliermarsh marked this pull request as draft June 7, 2026 12:09
@charliermarsh charliermarsh force-pushed the codex/ty-reachability-cache branch from 7d9ae1a to e8116b7 Compare June 7, 2026 12:16
@charliermarsh charliermarsh marked this pull request as ready for review June 7, 2026 12:17
@charliermarsh charliermarsh marked this pull request as draft June 7, 2026 16:00
@charliermarsh charliermarsh marked this pull request as ready for review June 7, 2026 16:42
@dhruvmanila

Copy link
Copy Markdown
Member

(Sorry, couldn't get to this today, will be looking at this first thing tomorrow.)

@charliermarsh

Copy link
Copy Markdown
Member Author

It's not urgent, feel free to prioritize other work above it. I appreciate the comment though!

@dhruvmanila dhruvmanila left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@charliermarsh charliermarsh force-pushed the codex/ty-reachability-cache branch from e8116b7 to 6810e53 Compare June 11, 2026 21:43
@charliermarsh charliermarsh enabled auto-merge (squash) June 11, 2026 22:01
@charliermarsh charliermarsh merged commit f0bcbba into main Jun 11, 2026
58 checks passed
@charliermarsh charliermarsh deleted the codex/ty-reachability-cache branch June 11, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants