Skip to content

Commit caa2420

Browse files
authored
chore: cache cpu feat check for micro-benchmarks (#7079)
Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
1 parent b1ab304 commit caa2420

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

vortex-buffer/benches/vortex_bitbuffer.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ use vortex_buffer::BitBuffer;
1212
use vortex_buffer::BitBufferMut;
1313

1414
fn main() {
15+
// Pre-warm CPUID feature detection so the one-time probe cost is never
16+
// included in any benchmark iteration.
17+
#[cfg(target_arch = "x86_64")]
18+
{
19+
let _ = is_x86_feature_detected!("avx2");
20+
let _ = is_x86_feature_detected!("avx512f");
21+
let _ = is_x86_feature_detected!("avx512vpopcntdq");
22+
}
23+
1524
divan::main();
1625
}
1726

@@ -166,9 +175,6 @@ fn slice_arrow_buffer(bencher: Bencher, length: usize) {
166175
#[divan::bench(args = INPUT_SIZE)]
167176
fn true_count_vortex_buffer(bencher: Bencher, length: usize) {
168177
let buffer = BitBuffer::from_iter((0..length).map(true_count_pattern));
169-
// Preload cpuid flags, one slow run that does feature detection skews sampling thus leading to way too few runs when feature detection kicks in.
170-
#[cfg(target_arch = "x86_64")]
171-
let _ = is_x86_feature_detected!("avx2");
172178

173179
bencher
174180
.with_inputs(|| &buffer)

0 commit comments

Comments
 (0)