You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/08 12:50:37 UTC
(datafusion) 01/01: bench: introduce create_hash benchmarks (#25952)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-25952-64de4fc255edf4a50667921239070e0f7c428678
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 3ed377a0d0c1a5afe0471aa3c0dfb3eb16684806
Author: RIchard Baah <13...@users.noreply.github.com>
AuthorDate: Thu Oct 8 12:50:13 2026 +0000
bench: introduce create_hash benchmarks (#25952)
## 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 #123` indicates that this PR will close issue #123.
-->
- N/A — adds missing benchmark coverage.
## Rationale for this change
`create_hashes()` has no dedicated benchmarks, making it hard to measure
the impact of changes to hashing logic. covers all existing datatypes
<!--
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.
Please explain the problem you are trying to solve in terms of the
user-visible
behavior, rather than the implementation.
For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of
the
implementation. "COUNT(DISTINCT) returns wrong results when the column
contains
nulls" is the user-visible problem.
-->
## What changes are included in this PR?
adds benchmarks for every datatype thats covered by `create_hashes()`
<!--
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.
-->
## What is the testing strategy for this PR?
n/a
<!--
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
Briefly describe how this PR is tested, and point to the specific tests
you added. For example: 'This new feature is covered by the
`sqllogictest` cases added in `foo.slt`'.
If this PR does not add tests, explain why. For example, if the change
is already covered by existing tests, please mention it.
You should also check the `codecov` bot reply on this PR to confirm the
changed code is exercised.
-->
## 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.
-->
---
datafusion/common/benches/with_hashes.rs | 68 ++++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 4 deletions(-)
diff --git a/datafusion/common/benches/with_hashes.rs b/datafusion/common/benches/with_hashes.rs
index ea75b32bdd..fe7ddca2f9 100644
--- a/datafusion/common/benches/with_hashes.rs
+++ b/datafusion/common/benches/with_hashes.rs
@@ -18,9 +18,10 @@
//! Benchmarks for `with_hashes` function
use arrow::array::{
- Array, ArrayRef, ArrowPrimitiveType, DictionaryArray, GenericStringArray, Int32Array,
- Int64Array, ListArray, MapArray, NullBufferBuilder, OffsetSizeTrait, PrimitiveArray,
- RunArray, StringViewArray, StructArray, UnionArray, make_array,
+ Array, ArrayRef, ArrowPrimitiveType, DictionaryArray, FixedSizeListArray,
+ GenericStringArray, Int32Array, Int64Array, ListArray, ListViewArray, MapArray,
+ NullArray, NullBufferBuilder, OffsetSizeTrait, PrimitiveArray, RunArray,
+ StringViewArray, StructArray, UnionArray, make_array,
};
use arrow::buffer::{NullBuffer, OffsetBuffer, ScalarBuffer};
use arrow::datatypes::{
@@ -127,6 +128,21 @@ fn criterion_benchmark(c: &mut Criterion) {
array: create_run_array::<Int32Type>(BATCH_SIZE),
supports_nulls: true,
},
+ BenchData {
+ name: "null",
+ array: Arc::new(NullArray::new(BATCH_SIZE)),
+ supports_nulls: false,
+ },
+ BenchData {
+ name: "list_view_array",
+ array: list_view_array(BATCH_SIZE),
+ supports_nulls: true,
+ },
+ BenchData {
+ name: "fixed_size_list_array",
+ array: fixed_size_list_array(BATCH_SIZE),
+ supports_nulls: true,
+ },
];
for BenchData {
@@ -603,5 +619,49 @@ where
)
}
-criterion_group!(benches, criterion_benchmark, sliced_array_benchmark);
+fn list_view_array(num_rows: usize) -> ArrayRef {
+ let elements_per_row = 5;
+ let values = primitive_array::<Int64Type>(num_rows * elements_per_row);
+ let offsets: ScalarBuffer<i32> = (0..num_rows)
+ .map(|i| (i * elements_per_row) as i32)
+ .collect();
+ let sizes: ScalarBuffer<i32> =
+ (0..num_rows).map(|_| elements_per_row as i32).collect();
+ Arc::new(ListViewArray::new(
+ Arc::new(Field::new("item", DataType::Int64, true)),
+ offsets,
+ sizes,
+ values,
+ None,
+ ))
+}
+
+fn fixed_size_list_array(num_rows: usize) -> ArrayRef {
+ let list_size = 4;
+ Arc::new(FixedSizeListArray::new(
+ Arc::new(Field::new("item", DataType::Int64, true)),
+ list_size as i32,
+ primitive_array::<Int64Type>(num_rows * list_size),
+ None,
+ ))
+}
+
+/// Heterogeneous key columns
+fn mixed_columns_benchmark(c: &mut Criterion) {
+ let pool = StringPool::new(100, 64);
+ let int64 = primitive_array::<Int64Type>(BATCH_SIZE);
+ let utf8 = pool.string_array::<i32>(BATCH_SIZE);
+ let utf8_view = pool.string_view_array(BATCH_SIZE);
+ let arrays = vec![int64, utf8, utf8_view];
+ c.bench_function("mixed: 3 columns (int64, utf8, utf8_view)", |b| {
+ do_hash_test(b, &arrays)
+ });
+}
+
+criterion_group!(
+ benches,
+ criterion_benchmark,
+ sliced_array_benchmark,
+ mixed_columns_benchmark
+);
criterion_main!(benches);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org