Skip to content

Reduce memory used by diagnostics - #28951

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/28944-diagnostic-memory
Sep 27, 2026
Merged

charliermarsh merged 1 commit into
mainfrom
charlie/28944-diagnostic-memory

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Diagnostics with a single annotation or sub-diagnostic currently allocate space for four entries on the first insertion. Reserve space for one initially and let the vectors grow normally when additional entries are added.

@astral-sh-bot

astral-sh-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 38.57MB 38.57MB -0.01% (3.77kB) ⬇️
sphinx 174.54MB 174.46MB -0.04% (75.94kB) ⬇️
trio 94.68MB 94.51MB -0.18% (173.37kB) ⬇️
prefect 482.22MB 480.92MB -0.27% (1.30MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
check_file_impl 30.41kB 26.64kB -12.41% (3.77kB) ⬇️

sphinx

Name Old New Diff Outcome
check_file_impl 317.49kB 244.13kB -23.11% (73.36kB) ⬇️
infer_expression_types_impl 11.81MB 11.81MB -0.02% (2.11kB) ⬇️
infer_scope_types_impl 6.24MB 6.23MB -0.00% (240.00B) ⬇️
infer_definition_types 11.97MB 11.97MB -0.00% (240.00B) ⬇️

trio

Name Old New Diff Outcome
check_file_impl 625.66kB 453.82kB -27.47% (171.84kB) ⬇️
infer_expression_types_impl 6.08MB 6.08MB -0.02% (1.48kB) ⬇️
infer_definition_types 4.80MB 4.80MB -0.00% (48.00B) ⬇️

prefect

Name Old New Diff Outcome
check_file_impl 6.89MB 5.60MB -18.69% (1.29MB) ⬇️
infer_expression_types_impl 24.17MB 24.16MB -0.04% (9.26kB) ⬇️
infer_scope_types_impl 19.75MB 19.75MB -0.00% (720.00B) ⬇️
infer_definition_types 38.41MB 38.41MB -0.00% (576.00B) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@astral-sh-bot

astral-sh-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@codspeed

codspeed Bot commented Sep 27, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 19.13%

⚡ 10 improved benchmarks
✅ 209 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory linter/all-with-preview-rules[unicode/pypinyin.py] 203.9 KB 161.1 KB +26.61%
⚡ Memory linter/all-rules[unicode/pypinyin.py] 199.3 KB 158 KB +26.16%
⚡ Memory linter/all-with-preview-rules[large/dataset.py] 1,091.1 KB 893.6 KB +22.09%
⚡ Memory linter/all-rules[large/dataset.py] 1,061.7 KB 873.7 KB +21.52%
⚡ Memory linter/all-with-preview-rules[pydantic/types.py] 624.9 KB 522.4 KB +19.62%
⚡ Memory linter/all-with-preview-rules[numpy/ctypeslib.py] 299.1 KB 251.4 KB +18.99%
⚡ Memory linter/all-rules[pydantic/types.py] 607.4 KB 510.7 KB +18.93%
⚡ Memory linter/all-rules[numpy/ctypeslib.py] 271.1 KB 232.3 KB +16.71%
⚡ Memory linter/all-with-preview-rules[numpy/globals.py] 58.8 KB 52.9 KB +11.07%
⚡ Memory linter/all-rules[numpy/globals.py] 58 KB 52.4 KB +10.69%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing charlie/28944-diagnostic-memory (73f9f3c) with main (a1f59fb)

Open in CodSpeed

@MichaReiser

Copy link
Copy Markdown
Member

Neat. I also wondered if it made sense for us to use SmallVec in some places, given that Diagnostics are Arced

@charliermarsh
charliermarsh marked this pull request as ready for review September 27, 2026 15:27
@charliermarsh
charliermarsh requested a review from a team as a code owner September 27, 2026 15:27
@astral-sh-bot
astral-sh-bot Bot requested a review from MichaReiser September 27, 2026 15:28
@charliermarsh charliermarsh added the performance Potential performance improvement label Sep 27, 2026
@charliermarsh
charliermarsh merged commit 25b90de into main Sep 27, 2026
72 checks passed
@charliermarsh
charliermarsh deleted the charlie/28944-diagnostic-memory branch September 27, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants