You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support zero copy hash repartitioning for Hash Aggregate #15383
changed the title [-]Support zero copy hash repartitioning inside Hash Aggregate[/-][+]Support zero copy hash repartitioning for Hash Aggregate[/+]on Mar 24, 2025
Based on goldmedal#3, I did the some benchmarks(clieckbench_1, h2o_medium) for it. feat_zero-copy-hash-agg-false is the branch that disables the configuration. feat_zero-copy-hash-agg is the branch enabling the configuration.
In conclusion, HashAggregate is slower in the selection vector mode.
I tried to profile Clickbench QQuery 4:
When selection vector enable:
When selection vector disabled:
In the current implementation, the CPU time of filter_record_batch (3.45%) is significantly greater than take_arrays(0.35%).
Does arrow have a more efficient way to filter a record batch by a boolean array?
I'm considering another approach. Maybe I shouldn't use filter_record_batch 🤔. It filters the all column iteratly. I should filter the row when the accumulator merge_batch 🤔
I'll draft another PR for the approach.
I'm considering another approach. Maybe I shouldn't use filter_record_batch 🤔. It filters the all column iteratly. I should filter the row when the accumulator merge_batch 🤔 I'll draft another PR for the approach.
Agree with you, we should try to avoid directly operate on the record batch.
I'm considering another approach. Maybe I shouldn't use filter_record_batch 🤔. It filters the all column iteratly. I should filter the row when the accumulator merge_batch 🤔
I'm considering another approach. Maybe I shouldn't use filter_record_batch 🤔. It filters the all column iteratly. I should filter the row when the accumulator merge_batch 🤔
I think also need to filter rows in GroupValues::intern, too.
I have another implementation for this issue goldmedal#4
The concept is that getting the row according to indices in the selection vector instead of going through all the rows in the batch.
Because it may involve many changes, I want to check if the implementations make sense.
Currently, I only implement GroupValuesPrimitive::intern for the group-by values. For the aggregation, I only implement count and some aggregations that use GroupsAccumulator.
Activity
[-]Support zero copy hash repartitioning inside Hash Aggregate[/-][+]Support zero copy hash repartitioning for Hash Aggregate[/+]goldmedal commentedon Mar 25, 2025
take
goldmedal commentedon Mar 29, 2025
@Dandandan
I have a draft goldmedal#3 based on #15423 for
HashAggregate. Could you check if it's heading in the right direction?When the selection vector mode is enabled:
CoalesceBatchesExecis not added forFinalPartitioned.The plan looks like this:
I'll review more aggregation patterns and add additional tests.
Thanks.
goldmedal commentedon Mar 31, 2025
Based on goldmedal#3, I did the some benchmarks(
clieckbench_1,h2o_medium) for it.feat_zero-copy-hash-agg-falseis the branch that disables the configuration.feat_zero-copy-hash-aggis the branch enabling the configuration.In conclusion, HashAggregate is slower in the selection vector mode.
I tried to profile Clickbench QQuery 4:

When selection vector enable:
When selection vector disabled:

In the current implementation, the CPU time of
filter_record_batch(3.45%) is significantly greater thantake_arrays(0.35%).Does arrow have a more efficient way to filter a record batch by a boolean array?
goldmedal commentedon Mar 31, 2025
I'm considering another approach. Maybe I shouldn't use
filter_record_batch🤔. It filters the all column iteratly. I should filter the row when the accumulatormerge_batch🤔I'll draft another PR for the approach.
zebsme commentedon Mar 31, 2025
Agree with you, we should try to avoid directly operate on the record batch.
Dandandan commentedon Mar 31, 2025
Yes, doing so will copy the entire batch (which is what we try to avoid) and will be slower than
take(in the end it will do the same).I think what we probably want is to get the indices via https://docs.rs/arrow/latest/arrow/buffer/struct.BooleanBuffer.html#method.set_indices so it only will aggregate the values for those indices.
Rachelint commentedon Apr 2, 2025
I think also need to filter rows in
GroupValues::intern, too.goldmedal commentedon Apr 20, 2025
I have another implementation for this issue goldmedal#4
The concept is that getting the row according to indices in the selection vector instead of going through all the rows in the batch.
Because it may involve many changes, I want to check if the implementations make sense.
Currently, I only implement
GroupValuesPrimitive::internfor the group-by values. For the aggregation, I only implementcountand some aggregations that useGroupsAccumulator.I also did some optimization for the sv-mode repartition https://github.com/apache/datafusion/pull/15423/files#r2051721176.
However, I found the performance won't be better for Clickbench queries 4 and 7.
I'm not sure if I'm on the right way 🤔
@Dandandan @Rachelint Do you have any suggestions for it?
Rachelint commentedon Apr 21, 2025
I think it may be possible that the test queries can't reflect the improvement well.
I may try to make some cases this evening.