Skip to content

Commit 2a5b1a7

Browse files
bench: track small u8 dictionary take (#9566)
Signed-off-by: Joseph Isaacs <joseph-isaacs@users.noreply.github.com>
1 parent ae8fddc commit 2a5b1a7

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎vortex-array/benches/take_primitive.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ fn main() {
2929
/// Number of indices to take. The top tier is sized to keep CodSpeed simulation under 1ms.
3030
const NUM_INDICES: &[usize] = &[1_000, 10_000, 25_000];
3131

32+
/// Large enough to measure both cache-resident and streaming dictionary decoding.
33+
const GT_NUM_INDICES: &[usize] = &[1_000_000, 16_000_000];
34+
3235
/// Size of the source vector / dictionary values.
3336
const VECTOR_SIZE: &[usize] = &[16, 256, 2048, 8192];
3437

@@ -90,3 +93,28 @@ fn dict_canonicalize_zipfian<const NUM_VALUES: usize>(bencher: Bencher, num_indi
9093
.with_inputs(|| (&dict, SESSION.create_execution_ctx()))
9194
.bench_refs(|(dict, ctx)| (*dict).clone().into_array().execute::<Canonical>(ctx));
9295
}
96+
97+
/// StatPopGen GT distribution: 75.21% 0, 3.85% 1, 0.45% 2, and 20.49% null.
98+
#[vortex_bench_support::cpu_features]
99+
#[divan::bench(args = GT_NUM_INDICES)]
100+
fn dict_canonicalize_gt_u8(bencher: Bencher, num_indices: usize) {
101+
let values = PrimitiveArray::from_option_iter([Some(0u8), Some(1), Some(2), None]);
102+
let range = Uniform::new(0u16, 10_000).unwrap();
103+
let codes = PrimitiveArray::from_iter(
104+
StdRng::seed_from_u64(0)
105+
.sample_iter(range)
106+
.take(num_indices)
107+
.map(|sample| match sample {
108+
0..7521 => 0u8,
109+
7521..7906 => 1,
110+
7906..7951 => 2,
111+
_ => 3,
112+
}),
113+
);
114+
let dict = DictArray::try_new(codes.into_array(), values.into_array()).unwrap();
115+
116+
bencher
117+
.counter(ItemsCount::new(num_indices))
118+
.with_inputs(|| (&dict, SESSION.create_execution_ctx()))
119+
.bench_refs(|(dict, ctx)| (*dict).clone().into_array().execute::<Canonical>(ctx));
120+
}

0 commit comments

Comments
 (0)