Skip to content

Commit cc018ee

Browse files
authored
Blocked BitPacked: encode blocked bitwidths (#10203)
Signed-off-by: Matt Katz <[email protected]>
1 parent d14fa26 commit cc018ee

6 files changed

Lines changed: 709 additions & 11 deletions

File tree

‎encodings/fastlanes/Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ harness = false
6969
name = "bitpack_compare_sweep"
7070
harness = false
7171

72+
[[bench]]
73+
name = "bitpack_blocked"
74+
harness = false
75+
7276
[[bench]]
7377
name = "cast_bitpacked"
7478
harness = false
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
//! Benchmarks `bitpack_encode_blocked`, which packs every 1024-value block at its own bit width.
5+
6+
#![expect(clippy::unwrap_used)]
7+
8+
use std::sync::LazyLock;
9+
10+
use divan::Bencher;
11+
use divan::counter::ItemsCount;
12+
use mimalloc::MiMalloc;
13+
use vortex_array::VortexSessionExecute;
14+
use vortex_array::arrays::PrimitiveArray;
15+
use vortex_fastlanes::bitpack_compress::bitpack_encode_blocked;
16+
use vortex_session::VortexSession;
17+
18+
#[global_allocator]
19+
static GLOBAL: MiMalloc = MiMalloc;
20+
21+
fn main() {
22+
divan::main();
23+
}
24+
25+
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
26+
let session = vortex_array::array_session();
27+
vortex_fastlanes::initialize(&session);
28+
session
29+
});
30+
31+
/// 64 blocks of `u32`, 256 KiB in all: shorter iterations are noisy on the walltime legs.
32+
const NUM_BLOCKS: usize = 64;
33+
34+
#[vortex_bench_support::cpu_features]
35+
#[divan::bench]
36+
fn bitpack_blocked_compress(bencher: Bencher) {
37+
// Block widths cycle from 1 to 16 bits, so the blocks take different packing kernels.
38+
let bit_widths: Vec<u8> = (1..=16).cycle().take(NUM_BLOCKS).collect();
39+
let array = PrimitiveArray::from_iter(bit_widths.iter().flat_map(|&bit_width| {
40+
(0..1024u32).map(move |i| i.wrapping_mul(7919) & ((1 << bit_width) - 1))
41+
}));
42+
43+
bencher.counter(ItemsCount::new(array.len())).bench(|| {
44+
bitpack_encode_blocked(
45+
&array,
46+
&bit_widths,
47+
Some(0),
48+
&mut SESSION.create_execution_ctx(),
49+
)
50+
.unwrap()
51+
});
52+
}

0 commit comments

Comments
 (0)