This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 258b0d2031 Bench: Cover Boolean filtering and oversized dictionaries
(#12054)
258b0d2031 is described below
commit 258b0d203168186a9ed8064ae3c135f7b921b1e7
Author: RIchard Baah <[email protected]>
AuthorDate: Wed Nov 4 01:09:22 2026 +0000
Bench: Cover Boolean filtering and oversized dictionaries (#12054)
# Which issue does this PR close?
Part of #11885. Adds benchmark coverage for #11901 and #12008, and
follows up on the Boolean filter coverage requested in
[#11918](https://github.com/apache/arrow-rs/pull/11918#discussion_r4395258002).
This consolidates and supersedes #11980 and #12041.
# Why is this change needed?
The existing suites do not cover Boolean arrays as filter data or the
cost of operating on small key ranges backed by oversized dictionaries.
They also do not exercise the 16-values-per-selected-key boundary
between dense and sparse dictionary mappings.
# What changes are included in this PR?
- Adds nullable and non-null Boolean filter cases across the existing
selectivities.
- Adds prepared `RowConverter` cases for rotating 8,192-key ranges
backed by unique string dictionaries with 1M and 4M values.
- Measures the full-value encoding cost from #11901 without including
`RowConverter` construction.
- Adds concat cases for 12 distinct dictionaries sliced to 682 keys,
with 12, 16, and 24 values per selected key.
- Straddles #12008's 16-values-per-selected-key cutoff so we can assess
the threshold.
# Are these changes tested?
Built and ran each filtered benchmark locally.
Benchmark bot runs:
-
[`filter_kernels`](https://github.com/apache/arrow-rs/pull/12054#issuecomment-6608333902)
-
[`row_format`](https://github.com/apache/arrow-rs/pull/12054#issuecomment-6608249174)
-
[`concatenate_kernel`](https://github.com/apache/arrow-rs/pull/12054#issuecomment-6608296873)
# Are there any significant user-facing changes?
No. This only adds benchmark coverage.
---
arrow/benches/concatenate_kernel.rs | 26 ++++++++++++++++++++++++++
arrow/benches/filter_kernels.rs | 18 ++++++++++++------
arrow/benches/row_format.rs | 30 +++++++++++++++++++++++++++++-
3 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/arrow/benches/concatenate_kernel.rs
b/arrow/benches/concatenate_kernel.rs
index fbc2e87c72..7545ad6503 100644
--- a/arrow/benches/concatenate_kernel.rs
+++ b/arrow/benches/concatenate_kernel.rs
@@ -198,6 +198,32 @@ fn add_benchmark(c: &mut Criterion) {
b.iter(|| bench_concat(&v1, &v2))
});
+ const DICTIONARY_SLICE_ROWS: usize = 682;
+ const DICTIONARY_SLICE_COUNT: usize = 12;
+ for values_per_key in [12, 16, 24] {
+ let values_len = DICTIONARY_SLICE_ROWS * values_per_key;
+ let inputs = (0..DICTIONARY_SLICE_COUNT)
+ .map(|dictionary_idx| {
+ let values = StringArray::from_iter_values(
+ (0..values_len).map(|value_idx|
format!("{dictionary_idx:02}_{value_idx:017}")),
+ );
+ let keys = Int32Array::from_iter_values(0..values_len as i32);
+ let dictionary = DictionaryArray::<Int32Type>::new(keys,
Arc::new(values));
+ dictionary.slice(values_len - DICTIONARY_SLICE_ROWS,
DICTIONARY_SLICE_ROWS)
+ })
+ .collect::<Vec<_>>();
+ let arrays = inputs
+ .iter()
+ .map(|array| array as &dyn Array)
+ .collect::<Vec<_>>();
+ c.bench_function(
+ &format!(
+ "concat str_dict_slice rows={DICTIONARY_SLICE_ROWS}
values_per_key={values_per_key} count={DICTIONARY_SLICE_COUNT}"
+ ),
+ |b| b.iter(|| bench_concat_arrays(&arrays)),
+ );
+ }
+
let v1 = FixedSizeListArray::try_new(
Arc::new(Field::new_list_field(DataType::Int32, true)),
1024,
diff --git a/arrow/benches/filter_kernels.rs b/arrow/benches/filter_kernels.rs
index 8b2d454233..dd2ce443d4 100644
--- a/arrow/benches/filter_kernels.rs
+++ b/arrow/benches/filter_kernels.rs
@@ -374,7 +374,7 @@ fn add_benchmark(c: &mut Criterion) {
b.iter(|| bench_built_filter(&data_array, &sparse_filter))
});
- let mut add_benchmark_for_nested = |name: &str, data_array: &dyn Array| {
+ let mut add_benchmark_for_array = |name: &str, data_array: &dyn Array| {
c.bench_function(&format!("filter {name} (kept 1/2)"), |b| {
b.iter(|| bench_filter(data_array, &filter_array))
});
@@ -400,20 +400,26 @@ fn add_benchmark(c: &mut Criterion) {
);
};
+ let data_array = create_boolean_array(size, 0.0, 0.5);
+ add_benchmark_for_array("boolean", &data_array);
+
+ let data_array = create_boolean_array(size, 0.1, 0.5);
+ add_benchmark_for_array("boolean w NULLs", &data_array);
+
let data_array = create_primitive_list_array::<i32, Int32Type>(size, 0.1,
0.1, 16);
- add_benchmark_for_nested("list<i32> w NULLs", &data_array);
+ add_benchmark_for_array("list<i32> w NULLs", &data_array);
let data_array = create_struct_list_array(size, 0.1, 16);
- add_benchmark_for_nested("list<struct<i64, utf8>> w NULLs", &data_array);
+ add_benchmark_for_array("list<struct<i64, utf8>> w NULLs", &data_array);
let data_array = create_primitive_fixed_size_list_array::<Int32Type>(size,
0.1, 0.1, 8);
- add_benchmark_for_nested("fixed_size_list<i32> w NULLs", &data_array);
+ add_benchmark_for_array("fixed_size_list<i32> w NULLs", &data_array);
let data_array = create_struct_fixed_size_list_array(size, 8);
- add_benchmark_for_nested("fixed_size_list<struct<i64, utf8>>",
&data_array);
+ add_benchmark_for_array("fixed_size_list<struct<i64, utf8>>", &data_array);
let data_array = create_string_map_array::<Int64Type>(size, 0.1, 16, 8);
- add_benchmark_for_nested("map<utf8, i64> w NULLs", &data_array);
+ add_benchmark_for_array("map<utf8, i64> w NULLs", &data_array);
}
criterion_group!(benches, add_benchmark);
diff --git a/arrow/benches/row_format.rs b/arrow/benches/row_format.rs
index 09d3800fae..04205b57a3 100644
--- a/arrow/benches/row_format.rs
+++ b/arrow/benches/row_format.rs
@@ -18,7 +18,7 @@
#[macro_use]
extern crate criterion;
-use arrow::array::ArrayRef;
+use arrow::array::{ArrayRef, DictionaryArray, Int32Array, StringArray};
use arrow::datatypes::{Int64Type, UInt64Type};
use arrow::row::{RowConverter, SortField};
use arrow::util::bench_util::{
@@ -282,6 +282,34 @@ fn row_bench(c: &mut Criterion) {
let cols = vec![Arc::new(dict) as ArrayRef];
do_bench(c, "4096 string_dictionary_low_cardinality(100, 0)", cols);
+ const ROWS: usize = 8_192;
+ for values_len in [1_000_000, 4_000_000] {
+ let values = Arc::new(StringArray::from_iter_values(
+ (0..values_len).map(|idx| format!("value_{idx}")),
+ ));
+ let chunks = (0..values_len / ROWS)
+ .map(|chunk| {
+ let start = chunk * ROWS;
+ let keys =
+ Int32Array::from_iter_values((start..start +
ROWS).map(|key| key as i32));
+ let dictionary =
+ DictionaryArray::<Int32Type>::try_new(keys,
values.clone()).unwrap();
+ vec![Arc::new(dictionary) as ArrayRef]
+ })
+ .collect::<Vec<_>>();
+ let converter =
+
RowConverter::new(vec![SortField::new(chunks[0][0].data_type().clone())]).unwrap();
+ let mut chunks = chunks.iter().cycle();
+ c.bench_function(
+ &format!("convert_columns_prepared {ROWS}
string_dictionary({values_len} values)"),
+ |b| {
+ b.iter(|| {
+
hint::black_box(converter.convert_columns(chunks.next().unwrap()).unwrap())
+ })
+ },
+ );
+ }
+
let cols = vec![
Arc::new(create_string_array_with_len::<i32>(4096, 0.5, 20)) as
ArrayRef,
Arc::new(create_string_array_with_len::<i32>(4096, 0., 30)) as
ArrayRef,