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

Skip to content

[ty] Compact retained use-def bindings#25682

Merged
charliermarsh merged 5 commits into
mainfrom
charlie/reduce-retained-semantic-index-memory
Jun 6, 2026
Merged

[ty] Compact retained use-def bindings#25682
charliermarsh merged 5 commits into
mainfrom
charlie/reduce-retained-semantic-index-memory

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

UseDefMap currently retains every interned binding state as a SmallVec, including builder-only capacity and an optional unbound constraint that are no longer needed after semantic indexing finishes.

This change packs the shadowing policy into the scope-local definition ID and stores retained binding states as ranges into one contiguous LiveBinding array. Binding construction and interning behavior remain unchanged, while each LiveBinding shrinks from 16 to 12 bytes and retained states no longer carry per-vector allocation metadata.

On a large codebase, this reduced retained memory by 2.96% without a wall-time regression.

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

astral-sh-bot Bot commented Jun 5, 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 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.

@astral-sh-bot

astral-sh-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 36.77MB 35.58MB -3.23% (1.19MB) ⬇️
trio 91.43MB 88.64MB -3.06% (2.79MB) ⬇️
sphinx 215.76MB 209.28MB -3.01% (6.49MB) ⬇️
prefect 587.41MB 567.79MB -3.34% (19.62MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
semantic_index 10.90MB 9.71MB -10.88% (1.19MB) ⬇️
get_loop_header 14.12kB 13.96kB -1.16% (168.00B) ⬇️

trio

Name Old New Diff Outcome
semantic_index 23.94MB 21.15MB -11.67% (2.79MB) ⬇️
get_loop_header 74.00kB 73.05kB -1.29% (976.00B) ⬇️

sphinx

Name Old New Diff Outcome
semantic_index 49.92MB 43.44MB -12.98% (6.48MB) ⬇️
get_loop_header 337.27kB 330.71kB -1.95% (6.56kB) ⬇️

prefect

Name Old New Diff Outcome
semantic_index 149.09MB 129.47MB -13.16% (19.62MB) ⬇️
get_loop_header 548.40kB 543.41kB -0.91% (4.98kB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review June 5, 2026 23:47
@astral-sh-bot astral-sh-bot Bot requested a review from dhruvmanila June 5, 2026 23:47
@charliermarsh charliermarsh added the performance Potential performance improvement label Jun 5, 2026
Comment thread crates/ty_python_core/src/use_def.rs Outdated
Comment thread crates/ty_python_core/src/use_def.rs Outdated
Comment thread crates/ty_python_core/src/use_def.rs Outdated
Comment thread crates/ty_python_core/src/use_def.rs Outdated
@charliermarsh charliermarsh force-pushed the charlie/reduce-retained-semantic-index-memory branch from 31223fc to 7148fb8 Compare June 6, 2026 18:01
@charliermarsh charliermarsh merged commit 2e6f8b8 into main Jun 6, 2026
59 checks passed
@charliermarsh charliermarsh deleted the charlie/reduce-retained-semantic-index-memory branch June 6, 2026 18:16
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.

3 participants