Skip to content

Conversation

@dqhl76
Copy link
Collaborator

@dqhl76 dqhl76 commented Dec 25, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

This PR included:

  1. Support for Two Shuffle Methods: Added support for both Row and Bucket shuffle modes. Please refer to the diagram below for a visual comparison of the differences.

  2. Recursive Spilling in Final Aggregate: Enabled the final aggregate processor to spill and restore data recursively. This enhancement not introduce performance regression compared to the previous implementation.

Reason for Dual Shuffle Methods:

Background: In our previous implementation, we used a "growth payload" strategy for the partial aggregation stage. While this dynamic approach was flexible and effective for varying data sizes, it necessitated an alignment processor (TransformPartitionBucket) and made implementing spilling support for the final aggregation difficult.

Solution: We moved to a fixed-bucket strategy determined at plan-time (based on node_num and thread_num). This symmetry between partial and final aggregation simplifies the architecture and enables simpler spilling support.

The Trade-off: With high concurrency (many nodes/threads), a purely fixed-bucket approach creates excessive buckets, degrading partial aggregation performance.

The Fix: We introduce a Row Shuffle method for high-concurrency scenarios. This forces the partial aggregation to use a single bucket, followed by a scatter operation to distribute data to the final aggregation processors, avoiding the overhead of managing too many buckets early in the pipeline.

image image

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Dec 25, 2025
refactor: refactor spiller

row shuffle spill

tmp save

clean

pass bucket partial force spill

pass tpch

basic pass

feat: add support for partitioned aggregate serialization and deserialization

save

remove unused activate_worker

refactor: also add stats for final aggregate

feat: implement configurable aggregate shuffle mode

refactor: add basic bucket level shuffled agg

refactor: remove legacy final agg

feat: refactor aggregate function in build_aggregate to make it clear
@dqhl76 dqhl76 added the ci-benchmark Benchmark: run all test label Jan 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

Docker Image for PR

  • tag: pr-19155-0907155-1767432417

note: this image tag is only available for internal use.

@dqhl76 dqhl76 added ci-benchmark Benchmark: run all test and removed ci-benchmark Benchmark: run all test labels Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Docker Image for PR

  • tag: pr-19155-3d71ace-1767663886

note: this image tag is only available for internal use.

@dqhl76 dqhl76 marked this pull request as ready for review January 7, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-benchmark Benchmark: run all test pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant