Skip to content

[ty] Remove per-scope tracking of reachability#24457

Merged
AlexWaygood merged 1 commit intomainfrom
alex/scope-memory
Apr 8, 2026
Merged

[ty] Remove per-scope tracking of reachability#24457
AlexWaygood merged 1 commit intomainfrom
alex/scope-memory

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood commented Apr 6, 2026

Summary

Same as #24472, but for the reachability field on Scope. We no longer need to track reachability of scopes; we can use the more generalised is_range_reachable method on SemanticIndex and iterate up through all parent scopes.

Performance is in the noise here -- maybe a 1% slowdown on a few benchmarks, but a 1% speedup on one microbenchmark.

Test Plan

Existing tests all pass

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Apr 6, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 6, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 87.72%. The percentage of expected errors that received a diagnostic held steady at 82.85%. The number of fully passing files held steady at 74/132.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 6, 2026

Memory usage report

Summary

Project Old New Diff Outcome
flake8 47.95MB 47.93MB -0.05% (23.05kB) ⬇️
trio 117.55MB 117.50MB -0.04% (42.43kB) ⬇️
sphinx 263.94MB 263.87MB -0.03% (72.38kB) ⬇️
prefect 715.65MB 715.47MB -0.03% (185.74kB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
semantic_index 13.72MB 13.70MB -0.16% (23.05kB) ⬇️

trio

Name Old New Diff Outcome
semantic_index 29.99MB 29.95MB -0.14% (42.48kB) ⬇️
infer_definition_types 7.63MB 7.63MB +0.00% (24.00B) ⬇️
infer_expression_types_impl 7.03MB 7.03MB +0.00% (24.00B) ⬇️
infer_scope_types_impl 4.77MB 4.77MB +0.00% (12.00B) ⬇️

sphinx

Name Old New Diff Outcome
semantic_index 61.13MB 61.06MB -0.12% (72.38kB) ⬇️

prefect

Name Old New Diff Outcome
semantic_index 172.49MB 172.31MB -0.11% (185.74kB) ⬇️

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Apr 6, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-await 40 0 0
invalid-return-type 1 0 0
Total 41 0 0

Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.

Full report with detailed diff (timing results)

@AlexWaygood AlexWaygood force-pushed the alex/scope-memory branch 2 times, most recently from 32eadbc to ce75456 Compare April 8, 2026 09:30
@AlexWaygood AlexWaygood added the internal An internal refactor or improvement label Apr 8, 2026
@AlexWaygood AlexWaygood changed the title [ty] Reduce memory usage of Scope [ty] Remove per-scope tracking of reachability Apr 8, 2026
@AlexWaygood AlexWaygood marked this pull request as ready for review April 8, 2026 10:01
Copy link
Copy Markdown
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Awesome, thank you.

Not sure what I did wrong when I tried to do the same.

@AlexWaygood AlexWaygood merged commit b6c69c2 into main Apr 8, 2026
53 checks passed
@AlexWaygood AlexWaygood deleted the alex/scope-memory branch April 8, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants