Repository navigation
Conversation
1c93e8c to
0539bfb
Compare
jayzhan211
left a comment
There was a problem hiding this comment.
@yashdotrv thanks for picking this up. Please correct the description, since most of the state is still unreserved and buffer growth is not the main cause. With the ignored #26705 cases in #26728 turned on, unreserved memory grows 121-124 MB for median (122-143 MB on main) and 500-505 MB for array_agg (531-589 MB), against a 16 MB bound. At the peak 19.1 MB of 152 MB is reserved for median, about one of the four partial states; the others appear to be queued in CoalescePartitionsExec.
A follow-up is fine because that queue is outside these streams, so #26705 should stay open. The description should also say that array_agg over 1000 groups at 30-60 MB goes from passing to ResourcesExhausted, while peak RSS at 100 MB stays near 610 MB.
|
@jayzhan211 ty for your review, I'll work on the suggestions and get back. |
0539bfb to
a7850b7
Compare
- Charge partial-state batches only when bytes per row exceed 1 KiB and total bytes exceed 64 KiB - Restore early break on soft group limit before table memory resize in FinalHashAggregateStream - Extract shared spill_table helper in FinalHashAggregateStream - Guard incoming batch memory reservation calculation to Partial input mode in AggregateStream - Replace synthetic tests with large-buffer retaining batches to properly test state batch admission - Add test for ClusteredFinalAggregateStream spill-and-retry on partial clustering - Add test for FinalHashAggregateStream spill-and-retry on large state batch - Restore aggregate_memory_call_sequence.rs to match main
|
@jayzhan211 Thanks again for the review and detailed pointers! I have updated the branch with the requested changes:
|
Which issue does this PR close?
Addresses #26705.
Rationale for this change
A partial aggregate can emit a state batch containing all its input values and then release its memory reservation. The final aggregate merges that batch before reserving memory for it. For aggregates such as
medianandarray_agg, this leaves input-sized state unaccounted for by the memory pool.What changes are included in this PR?
Final aggregates now reserve incoming state batches before merging them. The hash and clustered final paths can spill their current state and retry when the pool cannot admit a batch. I also updated the affected memory reservation and spill tests.
PR #26728 adds related memory accounting tests, but its cases for this issue are currently ignored.
What is the testing strategy for this PR?
I added reservation tests for the ungrouped, hash grouped, and clustered grouped final aggregate paths. The extended workspace test suite, formatting check, and Clippy pass.
I also ran the issue’s 30-million-row, four-partition
medianreproducer with a 300 MB memory limit. It now returnsResourcesExhaustedwhen the incoming state cannot be reserved. Peak RSS can still exceed the configured limit; reducing temporary memory use during buffer growth is outside this PR.Are there any user-facing changes?
Under memory pressure, a final aggregate may now spill or return
ResourcesExhaustedinstead of continuing with unreserved state. There are no public API changes.