Skip to content

Commit b45d295

Browse files
committed
Trim listview zip benchmark to a single mask shape
Reduce the divan bench to one Fragmented (alternating) mask with non-nullable and nullable inputs, and lower LEN to 8192 so each case stays well under a few hundred microseconds. The branchless chunked select is mask-shape-independent, so a single shape suffices; drop the now-unused MaskShape matrix. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent f05b6a0 commit b45d295

1 file changed

Lines changed: 18 additions & 38 deletions

File tree

vortex-array/benches/listview_zip.rs

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,29 @@ fn main() {
2020
divan::main();
2121
}
2222

23-
const LEN: usize = 65_536;
23+
// Smaller than the value-path benches: listview zip cost is dominated by element concatenation and
24+
// per-list canonicalization, so a few thousand lists already exercises the select while keeping the
25+
// benchmark well under a few hundred microseconds.
26+
const LEN: usize = 8_192;
2427

25-
#[divan::bench(args = [MaskShape::Fragmented, MaskShape::Block, MaskShape::Sparse, MaskShape::Dense])]
26-
fn nonnull(bencher: Bencher, shape: MaskShape) {
27-
run(
28-
bencher,
29-
list_view(0, false),
30-
list_view(1_000_000, false),
31-
shape,
32-
);
28+
/// Fragmented (alternating) mask: the worst case for the per-element branch this kernel replaces.
29+
/// The branchless chunked select is mask-shape-independent, so one shape suffices.
30+
fn mask() -> Mask {
31+
Mask::from_iter((0..LEN).map(|i| i.is_multiple_of(2)))
3332
}
3433

35-
#[divan::bench(args = [MaskShape::Fragmented, MaskShape::Block, MaskShape::Sparse, MaskShape::Dense])]
36-
fn nullable(bencher: Bencher, shape: MaskShape) {
37-
run(
38-
bencher,
39-
list_view(0, true),
40-
list_view(1_000_000, true),
41-
shape,
42-
);
34+
#[divan::bench]
35+
fn nonnull(bencher: Bencher) {
36+
run(bencher, list_view(0, false), list_view(1_000_000, false));
4337
}
4438

45-
fn run(bencher: Bencher, if_true: ArrayRef, if_false: ArrayRef, shape: MaskShape) {
46-
let mask = shape.mask(LEN);
39+
#[divan::bench]
40+
fn nullable(bencher: Bencher) {
41+
run(bencher, list_view(0, true), list_view(1_000_000, true));
42+
}
43+
44+
fn run(bencher: Bencher, if_true: ArrayRef, if_false: ArrayRef) {
45+
let mask = mask();
4746
bencher
4847
.with_inputs(|| {
4948
(
@@ -84,22 +83,3 @@ fn list_view(base: i64, nullable: bool) -> ArrayRef {
8483
.unwrap()
8584
.into_array()
8685
}
87-
88-
#[derive(Clone, Copy, Debug)]
89-
enum MaskShape {
90-
Fragmented,
91-
Block,
92-
Sparse,
93-
Dense,
94-
}
95-
96-
impl MaskShape {
97-
fn mask(self, len: usize) -> Mask {
98-
match self {
99-
MaskShape::Fragmented => Mask::from_iter((0..len).map(|i| i.is_multiple_of(2))),
100-
MaskShape::Block => Mask::from_iter((0..len).map(|i| (i / 128).is_multiple_of(2))),
101-
MaskShape::Sparse => Mask::from_iter((0..len).map(|i| i.is_multiple_of(10))),
102-
MaskShape::Dense => Mask::from_iter((0..len).map(|i| !i.is_multiple_of(10))),
103-
}
104-
}
105-
}

0 commit comments

Comments
 (0)