-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
perf: Drop RowConverter from GroupOrderingPartial #14566
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b22dab3
Benchmark partial ordering
ctsk 04528f8
Drop RowConverter from GroupOrderingPartial
ctsk 50df2b4
cargo fmt
ctsk 1ae5d74
Add license header
ctsk 5a88a02
Mark unused function argument
ctsk 2961710
cargo fmt
ctsk b12ac6b
fix typo
ctsk 8c882d9
Add TODO to remove _input_schema parameter
ctsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use std::sync::Arc; | ||
|
||
use arrow::array::{ArrayRef, Int32Array}; | ||
use arrow_schema::{DataType, Field, Schema, SortOptions}; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use datafusion_physical_expr::{expressions::col, LexOrdering, PhysicalSortExpr}; | ||
use datafusion_physical_plan::aggregates::order::GroupOrderingPartial; | ||
|
||
const BATCH_SIZE: usize = 8192; | ||
|
||
fn create_test_arrays(num_columns: usize) -> Vec<ArrayRef> { | ||
(0..num_columns) | ||
.map(|i| { | ||
Arc::new(Int32Array::from_iter_values( | ||
(0..BATCH_SIZE as i32).map(|x| x * (i + 1) as i32), | ||
)) as ArrayRef | ||
}) | ||
.collect() | ||
} | ||
fn bench_new_groups(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("group_ordering_partial"); | ||
|
||
// Test with 1, 2, 4, and 8 order indices | ||
for num_columns in [1, 2, 4, 8] { | ||
let fields: Vec<Field> = (0..num_columns) | ||
.map(|i| Field::new(format!("col{}", i), DataType::Int32, false)) | ||
.collect(); | ||
let schema = Schema::new(fields); | ||
|
||
let order_indices: Vec<usize> = (0..num_columns).collect(); | ||
let ordering = LexOrdering::new( | ||
(0..num_columns) | ||
.map(|i| { | ||
PhysicalSortExpr::new( | ||
col(&format!("col{}", i), &schema).unwrap(), | ||
SortOptions::default(), | ||
) | ||
}) | ||
.collect(), | ||
); | ||
|
||
group.bench_function(format!("order_indices_{}", num_columns), |b| { | ||
let batch_group_values = create_test_arrays(num_columns); | ||
let group_indices: Vec<usize> = (0..BATCH_SIZE).collect(); | ||
|
||
b.iter(|| { | ||
let mut ordering = | ||
GroupOrderingPartial::try_new(&schema, &order_indices, &ordering) | ||
.unwrap(); | ||
ordering | ||
.new_groups(&batch_group_values, &group_indices, BATCH_SIZE) | ||
.unwrap(); | ||
}); | ||
}); | ||
} | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, bench_new_groups); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not remove this arg?
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.
This way we can avoid API change, though I don't have a strong preference
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.
maybe we can add a comment or something as a follow on pr
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.
Additionally, the
input_schema
argument inorder::GroupOrdering::try_new
will also be unnecessarydatafusion/datafusion/physical-plan/src/aggregates/order/mod.rs
Lines 43 to 58 in 1626c00
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.
I've added a TODO comment to the code