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

Skip to content

[ty] Store common definition inference results inline#25814

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/inline-definition-inference-results
Jun 10, 2026
Merged

[ty] Store common definition inference results inline#25814
charliermarsh merged 1 commit into
mainfrom
charlie/inline-definition-inference-results

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

DefinitionInference almost always retains either one binding, one declaration, or a binding and declaration for the same definition and type. DefinitionTypes stored each of these common cases in a separate Box, adding a heap allocation for every cached result, while only the uncommon multi-result case needs out-of-line storage.

This stores the common singleton payloads directly in the enum and keeps the Other variant boxed. The cycle-normalization and iteration paths preserve the existing behavior while operating on the inline payloads.

On a representative project, this reduced retained memory from 287,972,361 bytes to 286,861,193 bytes, saving 1,111,168 bytes (0.39%) without diagnostic changes.

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

astral-sh-bot Bot commented Jun 10, 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.23%. The percentage of expected errors that received a diagnostic held steady at 87.42%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 35.39MB 35.36MB -0.09% (31.33kB) ⬇️
trio 87.77MB 87.65MB -0.13% (117.21kB) ⬇️
sphinx 207.60MB 207.20MB -0.19% (408.03kB) ⬇️
prefect 564.26MB 562.57MB -0.30% (1.68MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
infer_definition_types 1.58MB 1.53MB -2.78% (44.89kB) ⬇️
infer_deferred_types 429.47kB 443.04kB +3.16% (13.56kB) ⬇️

trio

Name Old New Diff Outcome
infer_definition_types 6.61MB 6.43MB -2.66% (180.38kB) ⬇️
infer_deferred_types 1.72MB 1.78MB +3.59% (63.17kB) ⬇️

sphinx

Name Old New Diff Outcome
infer_definition_types 20.74MB 20.21MB -2.54% (539.06kB) ⬇️
infer_deferred_types 3.89MB 4.01MB +3.29% (131.03kB) ⬇️

prefect

Name Old New Diff Outcome
infer_definition_types 75.97MB 74.05MB -2.54% (1.93MB) ⬇️
infer_deferred_types 8.75MB 9.00MB +2.83% (253.84kB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review June 10, 2026 12:37
@charliermarsh charliermarsh merged commit d36b3c5 into main Jun 10, 2026
59 checks passed
@charliermarsh charliermarsh deleted the charlie/inline-definition-inference-results branch June 10, 2026 12:37
@astral-sh-bot astral-sh-bot Bot requested a review from dhruvmanila June 10, 2026 12:37
@charliermarsh charliermarsh added the performance Potential performance improvement label Jun 10, 2026
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