Repository navigation
Shrink call keyword capacity - #26475
charliermarsh wants to merge 3 commits into
Conversation
|
are you taking over my unfinished PRs (feel free to do so, I haven't found any combination that's nice perf wise) |
|
No, I didn't see #26227 |
Merging this PR will improve performance by 6.39%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Memory | parser[large/dataset.py] |
776.3 KB | 729.7 KB | +6.39% |
Tip
Curious why this is faster? Use the CodSpeed MCP and ask your agent.
Comparing charlie/reduce-ast-keyword-capacity (b739bc8) with main (4b24ed1)
Footnotes
-
4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
Noooo, please fix it for me 😆 I already have way too many draft PRs |
|
Haha ok |
460dd4c to
7c1aec5
Compare
7c1aec5 to
b739bc8
Compare
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
sphinx
prefect
|
|
|
|
Is this too hard for both of us ;) |
Summary
Collect call keywords in a
Vec, then move them into an exactly sizedThinVecbefore retaining them in the AST. The ordinary conversion preserved theVec's spare capacity, while constructing and shrinking aThinVecdirectly added work to the hot parse loop. This keeps the original parsing path and performs one exact-capacity conversion at finalization.This reduces retained AST memory from 956,062 bytes to 899,358 bytes (-5.93%) and full parsed memory from 1,208,698 bytes to 1,151,994 bytes on the existing five-file benchmark corpus. ty's normalized
parsed_modulememory also fell by 32,384 bytes across three identical runs.The parser, AST, formatter, linter, and
ruff_dbtest suites pass (4,254 tests), with no snapshot changes, andprekpasses. This PR remains a draft while CodSpeed validates the revised construction strategy.