2010YOUY01 opened a new pull request, #25639:
URL: https://github.com/apache/datafusion/pull/25639

   # perf: Avoid copying when materializing output in 
OrderedFinalAggregateStream
   
   ## Which issue does this PR close?
   
   Closes [#25157](https://github.com/apache/datafusion/issues/25157).
   Follow-up to [#25312](https://github.com/apache/datafusion/pull/25312).
   
   ## Rationale for this change
   
   See [#25312](https://github.com/apache/datafusion/pull/25312) for the 
rationale and implementation details. This PR mechanically applies the same 
pattern to `OrderedFinalAggregateStream`.
   
   I repeated the original 10-million-row experiment on an M4 Pro MacBook Pro, 
with 14 partitions and `batch_size = 8192`:
   
   ```text
   main (already includes #25312):                 450.82 ms
   this PR:                                       329.25 ms
   legacy aggregation (migration disabled):        336.10 ms
   ```
   
   
   ## What changes are included in this PR?
   
   1. A clean-up refactor for `OrderedFinalAggregateStream` implementation, see 
https://github.com/apache/datafusion/issues/23974 for idea.
   2. Materialize all completed final results once and emit slices, retaining 
the output buffers' reservation until the last slice is handed off. If those 
buffers cannot be reserved, hand off the whole batch.
   3. Preserve spill replay and count its final output once in the operator 
metrics.
   
   To read this PR, start at `OrderedFinalAggregateStream::into_stream()`. Its 
stage diagram describes the execution flow, and the incremental-output notes 
link to the explanation in the partial stream.
   
   The diff is not easy to read directly due to the clean-up refactor
   
   
   ## What is the testing strategy for this PR?
   
   For correctness, existing tests have covered it.
   To prevent similar perf regression, we can do
   
   - #25310
   
   
   ## Are there any user-facing changes?
   
   Faster ordered final aggregation. Query results and public APIs are 
unchanged.
   


-- 
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