Repository navigation
Optimize Nullstate / accumulators - #19625
Conversation
|
run benchmark tpch |
|
run benchmarks |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
🤖: Benchmark completed Details
|
|
Looks like it is a nice win. |
|
run benchmarks |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
run benchmarks |
|
🤖 |
|
Benchmark script failed with exit code 101. Last 10 lines of output: Click to expand |
|
run benchmarks |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
run benchmarks |
|
🤖 |
|
run benchmark aggregate |
|
🤖 Hi @Dandandan, thanks for the request (#19625 (comment)).
Please choose one or more of these with |
|
run benchmark aggregate_query_sql aggregate_vectorized |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
Benchmark script failed with exit code 101. Last 10 lines of output: Click to expand |
|
run benchmark tpch_mem |
|
🤖 |
|
🤖: Benchmark completed Details
|
alamb
left a comment
There was a problem hiding this comment.
Thank you @Dandandan -- this looks good to me. I have some comment / structure comments but I don't think anything is needed prior to merge (we could do it as follow on PRs or never)
| // "not seen" valid) | ||
| let seen_values = | ||
| initialize_builder(&mut self.seen_values, total_num_groups, false); | ||
| if let SeenValues::All { num_values } = &mut self.seen_values |
There was a problem hiding this comment.
One possibility is to make this another another function to reduce some duplication and have a place it could be explained
Maybe something like
if let Some(num_values) = self.all_values_mut() && opt_filter.is_none && values.null_count == 0 {
...
}?
Though maybe an extra level of indirection would make it harder to follow.
| total_num_groups, | ||
| |group_index, new_value| { | ||
| let value = &mut self.values[group_index]; | ||
| // SAFETY: group_index is guaranteed to be in bounds |
There was a problem hiding this comment.
I recommend adding safety notes to the docs of GroupsAccumulator in https://github.com/apache/datafusion/blob/36ec9f1de0aeabca60b8f7ebe07d650b8ef03506/datafusion/expr-common/src/groups_accumulator.rs#L114-L113
That explains that all group indexes are guaranteed to be <= total_num_groups and that can be relied on for safety
|
run benchmark tpch_mem |
|
🤖 |
|
(will see if we can see a reproducable speedup) |
|
🤖: Benchmark completed Details
|
|
|
…umulator/accumulate.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
…umulator/accumulate.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
## 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. --> - Closes apache#19636 ## Rationale for this change Speedup accumulator code (sum, avg, count) by specializing on non-null cases. ## What changes are included in this PR? * Specialize `Nullstate` to non-null values. * Use unchecked indexing ## 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)? --> ## Are there any user-facing changes? <!-- 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. --> --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Which issue does this PR close?
Rationale for this change
Speedup accumulator code (sum, avg, count) by specializing on non-null cases.
What changes are included in this PR?
Nullstateto non-null values.Are these changes tested?
Are there any user-facing changes?