Shrink call keyword capacity#26475
Draft
charliermarsh wants to merge 3 commits into
Draft
Conversation
Member
|
are you taking over my unfinished PRs (feel free to do so, I haven't found any combination that's nice perf wise) |
Member
Author
|
No, I didn't see #26227 |
Merging this PR will improve performance by 6.39%
Performance Changes
Tip Curious why this is faster? Use the CodSpeed MCP and ask your agent. Comparing Footnotes
|
Member
|
Noooo, please fix it for me 😆 I already have way too many draft PRs |
Member
Author
|
Haha ok |
460dd4c to
7c1aec5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.