Repository navigation
Conversation
BufferExec's dam mode charged each buffered batch with get_array_memory_size(), so zero-copy slices of one large array (as aggregates emit) were each charged with the whole shared buffer. Use RecordBatchMemoryCounter, as the sort shuffle buffer does since apache#2796. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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?
No separate issue. Follow-up to #2796, split out of #2792.
Rationale for this change
#2796 made the sort shuffle buffer count each Arrow buffer once with DataFusion's
RecordBatchMemoryCounter, so zero-copy slices of one large array (as aggregates emit) are not each charged with the whole shared buffer.BufferExec's dam mode has the same problem and was left out of that PR: it reservesget_array_memory_size()per buffered batch, so ten slices of one batch reserve ten times the memory they actually hold. Over-reserving makes the dam break early under memory pressure, even though the real memory use would have fit.What changes are included in this PR?
BufferExec's dam fill phase reserves each batch's size from aRecordBatchMemoryCountershared across the buffered batches, so a buffer shared by several slices is charged once.dam_charges_buffer_shared_by_slices_once: it buffers ten slices of one 10,000-row batch and checks what stays reserved. Without the fix, 720,864 bytes stay reserved after the first drain (9 times the 80,096-byte shared buffer). With the fix, less than one buffer's worth does.dam_reservation_shrinks_incrementally_during_drainnow computes its expected sizes the same way.Are there any user-facing changes?
No.
🤖 Generated with Claude Code