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

Skip to content

[ty] Use compact frozen representation for narrowing constraints#25990

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/codex-frozen-narrowing
Jun 14, 2026
Merged

[ty] Use compact frozen representation for narrowing constraints#25990
charliermarsh merged 1 commit into
mainfrom
charlie/codex-frozen-narrowing

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 14, 2026

Copy link
Copy Markdown
Member

Summary

Narrowing analysis builds a map from each affected place to the constraint contributed by an expression or pattern. These results are cached, but once construction finishes we only read them; retaining each result as an FxHashMap therefore keeps hash-table storage that the cached value no longer needs.

This keeps FxHashMap in NarrowingConstraintsBuilder for efficient construction, then converts each completed result to a FrozenMap, whose sorted boxed slice provides binary-search lookup without retaining hash-table capacity.

In the memory report, this reduced retained memory for all_narrowing_constraints_for_expression by 40.1–45.6% across Flake8, Trio, Sphinx, and Prefect, reducing total retained memory by 0.2–1.1%. The typing-conformance and ecosystem comparisons reported no diagnostic changes.

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

astral-sh-bot Bot commented Jun 14, 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 14, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 34.04MB 33.97MB -0.20% (70.70kB) ⬇️
trio 83.37MB 82.96MB -0.49% (417.04kB) ⬇️
sphinx 195.77MB 194.03MB -0.89% (1.74MB) ⬇️
prefect 530.28MB 524.56MB -1.08% (5.72MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 161.51kB 90.81kB -43.77% (70.70kB) ⬇️

trio

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 1.01MB 621.85kB -40.14% (417.04kB) ⬇️

sphinx

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 4.04MB 2.31MB -42.92% (1.73MB) ⬇️
all_negative_narrowing_constraints_for_pattern 1008.00B 912.00B -9.52% (96.00B) ⬇️
all_narrowing_constraints_for_pattern 1.05kB 984.00B -8.89% (96.00B) ⬇️

prefect

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 12.56MB 6.84MB -45.58% (5.72MB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@charliermarsh charliermarsh added the performance Potential performance improvement label Jun 14, 2026
@charliermarsh charliermarsh marked this pull request as ready for review June 14, 2026 18:26
@charliermarsh charliermarsh changed the title [ty] Reduce memory for narrowing constraints [ty] Use compact frozen representation for narrowing constraints Jun 14, 2026
@charliermarsh charliermarsh merged commit f24da12 into main Jun 14, 2026
59 checks passed
@charliermarsh charliermarsh deleted the charlie/codex-frozen-narrowing branch June 14, 2026 18:26
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