-
Notifications
You must be signed in to change notification settings - Fork 990
Reduce overhead when computing compound hash-based groupby aggregations #20736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
9aa47e1
2a1e841
a530987
989e133
0ae3ad4
accbb0b
15a465e
43fff53
98d01ee
dc633e5
55d19f3
794c48b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -92,47 +92,54 @@ class groupby_simple_aggregations_collector final | |||||
|
|
||||||
| return aggs; | ||||||
| } | ||||||
|
|
||||||
| std::vector<std::unique_ptr<aggregation>> visit( | ||||||
| data_type, cudf::detail::correlation_aggregation const&) override | ||||||
| { | ||||||
| std::vector<std::unique_ptr<aggregation>> aggs; | ||||||
| aggs.push_back(make_sum_aggregation()); | ||||||
| // COUNT_VALID | ||||||
| aggs.push_back(make_count_aggregation()); | ||||||
|
|
||||||
| return aggs; | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| std::tuple<table_view, | ||||||
| cudf::detail::host_vector<aggregation::Kind>, | ||||||
| std::vector<std::unique_ptr<aggregation>>, | ||||||
| std::vector<int>, | ||||||
| bool> | ||||||
| extract_single_pass_aggs(host_span<aggregation_request const> requests, | ||||||
| rmm::cuda_stream_view stream) | ||||||
| { | ||||||
| std::vector<column_view> columns; | ||||||
| std::vector<std::unique_ptr<aggregation>> aggs; | ||||||
| std::vector<int> force_non_nullable; | ||||||
| auto agg_kinds = cudf::detail::make_empty_host_vector<aggregation::Kind>(requests.size(), stream); | ||||||
|
|
||||||
| bool has_compound_aggs = false; | ||||||
| for (auto const& request : requests) { | ||||||
| auto const& agg_v = request.aggregations; | ||||||
| auto const& input_aggs = request.aggregations; | ||||||
|
|
||||||
| // The set of input aggregations. | ||||||
| std::unordered_set<aggregation::Kind> input_agg_kinds_set; | ||||||
| for (auto const& agg : input_aggs) { | ||||||
| input_agg_kinds_set.insert(agg->kind); | ||||||
| } | ||||||
|
|
||||||
| // The aggregations extracted from the input request, including the original single-pass | ||||||
| // aggregations and the intermediate single-pass aggregations replacing compound | ||||||
| // aggregations. | ||||||
| std::unordered_set<aggregation::Kind> agg_kinds_set; | ||||||
|
|
||||||
| auto insert_agg = [&](column_view const& request_values, std::unique_ptr<aggregation>&& agg) { | ||||||
| if (agg_kinds_set.insert(agg->kind).second) { | ||||||
| // Check if the inserted aggregation is an input aggregation or a replacement aggregation. | ||||||
| // If it is not an input aggregation, we can force its output to be non-nullable | ||||||
| // (by storing `1` value in the `force_non_nullable` vector). | ||||||
| auto const is_input_agg = input_agg_kinds_set.contains(agg->kind); | ||||||
| force_non_nullable.push_back(is_input_agg ? 0 : 1); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the code to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is host-only, the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I found that the issue is due to implicit converting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I tried
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I tried to change so it makes more sense to change both together.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand. But it would require too many changes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||||
|
|
||||||
| agg_kinds.push_back(agg->kind); | ||||||
| aggs.push_back(std::move(agg)); | ||||||
| columns.push_back(request_values); | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| auto values_type = cudf::is_dictionary(request.values.type()) | ||||||
| ? cudf::dictionary_column_view(request.values).keys().type() | ||||||
| : request.values.type(); | ||||||
| for (auto const& agg : agg_v) { | ||||||
| auto const values_type = cudf::is_dictionary(request.values.type()) | ||||||
| ? cudf::dictionary_column_view(request.values).keys().type() | ||||||
| : request.values.type(); | ||||||
| for (auto const& agg : input_aggs) { | ||||||
| groupby_simple_aggregations_collector collector; | ||||||
| auto spass_aggs = agg->get_simple_aggregations(values_type, collector); | ||||||
| if (spass_aggs.size() > 1 || !spass_aggs.front()->is_equal(*agg)) { | ||||||
|
|
@@ -145,7 +152,11 @@ extract_single_pass_aggs(host_span<aggregation_request const> requests, | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| return {table_view(columns), std::move(agg_kinds), std::move(aggs), has_compound_aggs}; | ||||||
| return {table_view(columns), | ||||||
| std::move(agg_kinds), | ||||||
| std::move(aggs), | ||||||
| std::move(force_non_nullable), | ||||||
| has_compound_aggs}; | ||||||
| } | ||||||
|
|
||||||
| std::vector<aggregation::Kind> get_simple_aggregations(groupby_aggregation const& agg, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused code: correlation aggregation is not yet supported in hash-based pipeline.