You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "2010YOUY01 (via GitHub)" <gi...@apache.org> on 2026/09/23 00:57:42 UTC

[PR] perf: Improve output materializing speed for `OrderedFinalAggregateStream` [datafusion]

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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] perf: Improve output materializing speed for `OrderedFinalAggregateStream` [datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on PR #25639:
URL: https://github.com/apache/datafusion/pull/25639#issuecomment-5827104719

   > Should we backport this and related PRs to branch-55?
   
   I wouldn't mind it, but it's not a big deal since there's a documented workaround; great to have it fixed in 56, thanks!


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] perf: Improve output materializing speed for `OrderedFinalAggregateStream` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #25639:
URL: https://github.com/apache/datafusion/pull/25639


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] perf: Improve output materializing speed for `OrderedFinalAggregateStream` [datafusion]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25639:
URL: https://github.com/apache/datafusion/pull/25639#issuecomment-5787322827

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/25639?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `86.30137%` with `20 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 82.45%. Comparing base ([`0576a0b`](https://app.codecov.io/gh/apache/datafusion/commit/0576a0b400437ade5a6f3b102465d954a539f263?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`418dc7a`](https://app.codecov.io/gh/apache/datafusion/commit/418dc7a810f5d251b6dda968f1d2bd7556dbc520?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 22 commits behind head on main.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/25639?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...ysical-plan/src/aggregates/ordered\_final\_stream.rs](https://app.codecov.io/gh/apache/datafusion/pull/25639?src=pr&el=tree&filepath=datafusion%2Fphysical-plan%2Fsrc%2Faggregates%2Fordered_final_stream.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1wbGFuL3NyYy9hZ2dyZWdhdGVzL29yZGVyZWRfZmluYWxfc3RyZWFtLnJz) | 85.18% | [6 Missing and 14 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25639?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             main   #25639      +/-   ##
   ==========================================
   + Coverage   82.42%   82.45%   +0.03%     
   ==========================================
     Files        1139     1140       +1     
     Lines      435372   436247     +875     
     Branches   435372   436247     +875     
   ==========================================
   + Hits       358845   359709     +864     
   + Misses      54826    54773      -53     
   - Partials    21701    21765      +64     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/25639?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org