[ty] Use same-file expression inference in reachability#25694
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 92.16%. The percentage of expected errors that received a diagnostic held steady at 87.31%. The number of fully passing files held steady at 92/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
sphinx
trio
prefect
|
|
Merging this PR will not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | ty_micro[typevar_mapping_small_accumulations] |
13.3 MB | 14 MB | -5.26% |
| ❌ | Simulation | ty_micro[typevar_mapping_small_accumulations] |
210.2 ms | 219.3 ms | -4.16% |
| ⚡ | Simulation | ty_check_file[incremental] |
8.1 ms | 7.6 ms | +6% |
| ⚡ | Memory | ty_micro[typeis_narrowing] |
20 MB | 19 MB | +4.89% |
Tip
Investigate this regression with the CodSpeed MCP and your agent.
Comparing codex/ty-same-file-reachability (1f837a4) with main (3e70e4a)
Footnotes
-
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. ↩
AlexWaygood
approved these changes
Jun 6, 2026
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.
Summary
Reachability currently calls
infer_expression_typefor each expression that it evaluates. This creates and retains a separate Salsa query for every expression, even though reachability only evaluates predicates from the same file as the enclosing query.This uses
infer_same_file_expression_typeinstead. The underlyinginfer_expression_typesquery continues to provide caching and cycle recovery, while cross-file callers continue throughinfer_expression_type; reachability avoids retaining the redundant single-expression query layer.Across the memory-report projects, retained
infer_expression_type_implmemory fell by 88% to 95%, reducing total retained memory by 0.15% to 0.68% without diagnostic changes.