perf: sort replace free()->try_grow() pattern with try_resize() to reduce memory pool interactions#20729
Merged
mbutrovich merged 1 commit intoapache:mainfrom Mar 5, 2026
Merged
Conversation
…educe memory pool interactions.
12 tasks
EmilyMatt
approved these changes
Mar 5, 2026
Contributor
EmilyMatt
left a comment
There was a problem hiding this comment.
LGTM, Code also looks much cleaner!
26 tasks
andygrove
approved these changes
Mar 5, 2026
Member
andygrove
left a comment
There was a problem hiding this comment.
Thanks for the fix @mbutrovich!
Contributor
|
Thanks @mbutrovich I just checked that Reg to memory fragmentation |
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.
Which issue does this PR close?
Rationale for this change
See full discussion in #20728, but the tl;dr is:
What changes are included in this PR?
Replace the pattern of
free()->try_grow()with atry_resize()that in the common case doesn't do much work since a sorted output batch is likely the same size as the input batch.Are these changes tested?
Existing tests, and we are running some longer benchmarks with Comet at the moment.
When I profile TPC-H Q21 SF100 locally I see the giant stack of memory allocations that occur on DF52...


...completely disappear...
... and TPC-H Q21 looks back to DF51 performance, at least locally.
Are there any user-facing changes?
No.