Skip to content

Commit 20cd096

Browse files
authored
Add boolean benchmark for byte aligned slices (#8997)
# 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. - part of #8806 - Part of #8996 # Rationale for this change As part of #8996 I would like to add special case code for byte aligned boolean buffers, and to do so I would like to have benchmarks that cover this # What changes are included in this PR? 1. Add benchmark for offset of 24 bits (in addition to 1) # Are these changes tested? I ran it manually # Are there any user-facing changes? No
1 parent e49c2ed commit 20cd096

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

arrow/benches/boolean_kernels.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,31 @@ fn add_benchmark(c: &mut Criterion) {
4747
c.bench_function("or", |b| b.iter(|| bench_or(&array1, &array2)));
4848
c.bench_function("not", |b| b.iter(|| bench_not(&array1)));
4949

50-
let array1_slice = array1.slice(1, size - 1);
51-
let array1_slice = array1_slice
52-
.as_any()
53-
.downcast_ref::<BooleanArray>()
54-
.unwrap();
55-
let array2_slice = array2.slice(1, size - 1);
56-
let array2_slice = array2_slice
57-
.as_any()
58-
.downcast_ref::<BooleanArray>()
59-
.unwrap();
50+
// Slice by 1 (not aligned to byte (8 bit) or word (64 bit) boundaries)
51+
let offset = 1;
52+
let array1_slice = array1.slice(offset, size - offset);
53+
let array2_slice = array2.slice(offset, size - offset);
6054

61-
c.bench_function("and_sliced", |b| {
62-
b.iter(|| bench_and(array1_slice, array2_slice))
55+
c.bench_function("and_sliced_1", |b| {
56+
b.iter(|| bench_and(&array1_slice, &array2_slice))
6357
});
64-
c.bench_function("or_sliced", |b| {
65-
b.iter(|| bench_or(array1_slice, array2_slice))
58+
c.bench_function("or_sliced_1", |b| {
59+
b.iter(|| bench_or(&array1_slice, &array2_slice))
6660
});
67-
c.bench_function("not_sliced", |b| b.iter(|| bench_not(array1_slice)));
61+
c.bench_function("not_sliced_1", |b| b.iter(|| bench_not(&array1_slice)));
62+
63+
// Slice by 24 (aligned on byte (8 bit) but not word (64 bit) boundaries)
64+
let offset = 24;
65+
let array1_slice = array1.slice(offset, size - offset);
66+
let array2_slice = array2.slice(offset, size - offset);
67+
68+
c.bench_function("and_sliced_24", |b| {
69+
b.iter(|| bench_and(&array1_slice, &array2_slice))
70+
});
71+
c.bench_function("or_sliced_24", |b| {
72+
b.iter(|| bench_or(&array1_slice, &array2_slice))
73+
});
74+
c.bench_function("not_slice_24", |b| b.iter(|| bench_not(&array1_slice)));
6875
}
6976

7077
criterion_group!(benches, add_benchmark);

0 commit comments

Comments
 (0)