fix: Reduce memory spike in aggregate window functions#15711
Open
zhli1142015 wants to merge 3 commits intofacebookincubator:mainfrom
Open
fix: Reduce memory spike in aggregate window functions#15711zhli1142015 wants to merge 3 commits intofacebookincubator:mainfrom
zhli1142015 wants to merge 3 commits intofacebookincubator:mainfrom
Conversation
✅ Deploy Preview for meta-velox canceled.
|
Contributor
Author
|
@mbasmanova and @aditi-pandit could you please help to review? |
e793291 to
eed051e
Compare
Contributor
Author
|
CI failure is not related, #15697 |
Contributor
Author
|
cc @JkSelf also. |
eed051e to
8f24df8
Compare
8f24df8 to
e35c2d2
Compare
Contributor
|
cc: @kagamiori |
d71041d to
5ec7159
Compare
5ec7159 to
cfe1b37
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.
Reduce memory spike in aggregate window functions when using UNBOUNDED
PRECEDING AND UNBOUNDED FOLLOWING frame.
Previously, for window frames where all rows in a partition have the unbound frame
(e.g., UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING), the implementation would
allocate argument vectors for the entire partition at once via
fillArgVectors.For large partitions with millions of rows, this single massive allocation
causes a significant memory spike that can lead to OOM.
This change adds a dedicated
sameFrameAggregationpath that:allSameFrameinFrameMetadata.maxOutputBatchRowsconfig)instead of allocating one giant vector for the entire partition. This
significantly reduces peak memory usage.
output blocks can reuse the cached result without any data loading or
recomputation.
The fix reduces memory spike for queries like:
Peak Memory Before (4.2 G)
Peak Memory After (2.7 G)