Repository navigation
refactor(hash-aggr): Migrate single mode hash aggregation - #23408
Conversation
alamb
left a comment
There was a problem hiding this comment.
I hope to review this tomorrow
|
run benchmarks |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: clickbench_partitioned File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: tpch File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: tpcds File an issue against this benchmark runner |
alamb
left a comment
There was a problem hiding this comment.
Thank you @2010YOUY01 -- there are a few ignored results that I think are worth looking at, but otherwise this looks ready to go
cc @Rachelint
| let baseline_metrics = BaselineMetrics::new(&agg.metrics, partition); | ||
|
|
||
| // Preserve the existing aggregate metric surface for this plan node. | ||
| let _spill_metrics = SpillMetrics::new(&agg.metrics, partition); |
There was a problem hiding this comment.
This variable is ignored -- why bother to make it? Or is this a TODO when we implement spilling? If so, perhaps we can leave the TODO / link to more context
There was a problem hiding this comment.
Removed in b94c290
BTW now the only remaining work for this refactor is spilling for different aggregation modes
| hash_table: &mut AggregateHashTable<SingleMarker>, | ||
| ) -> Result<()> { | ||
| let input_schema = self.input.schema(); | ||
| self.input = Box::pin(EmptyRecordBatchStream::new(input_schema)); |
There was a problem hiding this comment.
maybe worth a comment that this eagerly releases the input stream
|
|
||
| match result { | ||
| Ok(Some(batch)) => { | ||
| let _ = self |
There was a problem hiding this comment.
I think we should return the error if the reservation fails (rather than ignoring it), right (as is done above in
if let Err(e) = self
.reservation
.try_resize(original_state.hash_table().memory_size())
{
return ControlFlow::Break((
Poll::Ready(Some(Err(e))),
original_state,
));
}|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetpch — base (merge-base)
tpch — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetpcds — base (merge-base)
tpcds — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usageclickbench_partitioned — base (merge-base)
clickbench_partitioned — branch
File an issue against this benchmark runner |
|
run benchmark clickbench_partitioned |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: clickbench_partitioned File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usageclickbench_partitioned — base (merge-base)
clickbench_partitioned — branch
File an issue against this benchmark runner |
|
@alamb Thank you for the review. Comments are addressed, and I plan to merge it tomorrow. |
Rachelint
left a comment
There was a problem hiding this comment.
Also looks good to me, thanks @2010YOUY01
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Part of apache#22710 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> This PRs implements the single aggregation (fused partial and final aggregation into a single physical plan operator). This mode can be planed if input is already hash/range partitioned. See comments at datafusion/physical-plan/src/aggregates/single_stream.rs for details. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - Adds an `AggregateHashTable<SingleMarker>` variant to handle single aggregation. - Adds `SingleHashAggregateStream` that uses `AggregateHashTable<SingleMarker>` to implement the single aggregation state machine. ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Existing tests for functionalities + UT for planning ## Are there any user-facing changes? No <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
Which issue does this PR close?
Rationale for this change
This PRs implements the single aggregation (fused partial and final aggregation into a single physical plan operator). This mode can be planed if input is already hash/range partitioned.
See comments at datafusion/physical-plan/src/aggregates/single_stream.rs for details.
What changes are included in this PR?
AggregateHashTable<SingleMarker>variant to handle single aggregation.SingleHashAggregateStreamthat usesAggregateHashTable<SingleMarker>to implement the single aggregation state machine.Are these changes tested?
Existing tests for functionalities + UT for planning
Are there any user-facing changes?
No