andygrove opened a new pull request, #2845:
URL: https://github.com/apache/datafusion-ballista/pull/2845

   # 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 
reserves `get_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 a 
`RecordBatchMemoryCounter` shared across the buffered batches, so a buffer 
shared by several slices is charged once.
   - New test `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_drain` now computes its 
expected sizes the same way.
   
   # Are there any user-facing changes?
   
   No.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to