Skip to content

Commit 6e4d7bd

Browse files
authored
fix: fixed seed for micro-benchmarks (#5574)
Signed-off-by: Alexander Droste <[email protected]>
1 parent 88f8f42 commit 6e4d7bd

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

bench-vortex/src/datasets/struct_list_of_ints.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use anyhow::Result;
55
use async_trait::async_trait;
66
use rand::Rng;
77
use rand::SeedableRng;
8+
use rand::rngs::StdRng;
89
use vortex::ArrayRef;
910
use vortex::IntoArray;
1011
use vortex::arrays::ChunkedArray;
@@ -46,7 +47,7 @@ impl Dataset for StructListOfInts {
4647
let names: FieldNames = (0..self.num_columns)
4748
.map(|col_idx| col_idx.to_string())
4849
.collect();
49-
let mut rng = rand::rngs::StdRng::seed_from_u64(0);
50+
let mut rng = StdRng::seed_from_u64(0);
5051

5152
let rows_per_chunk = (self.row_count / self.chunk_count).max(1usize);
5253
let chunks: Result<Vec<_>> = (0..self.row_count)

encodings/fastlanes/benches/bitpacking_take.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rand::Rng;
99
use rand::SeedableRng;
1010
use rand::distr::Uniform;
1111
use rand::prelude::StdRng;
12-
use rand::rng;
1312
use vortex_array::IntoArray as _;
1413
use vortex_array::arrays::PrimitiveArray;
1514
use vortex_array::compute::take;
@@ -100,7 +99,7 @@ fn take_200k_first_chunk_only(bencher: Bencher) {
10099
}
101100

102101
fn fixture(len: usize, bits: usize) -> Buffer<u32> {
103-
let rng = rng();
102+
let rng = StdRng::seed_from_u64(0);
104103
let range = Uniform::new(0_u32, 2_u32.pow(bits as u32)).unwrap();
105104
rng.sample_iter(range).take(len).collect()
106105
}

vortex/benches/common_encoding_tree_throughput.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ macro_rules! with_counter {
6363
// Encoding tree setup functions
6464

6565
mod setup {
66+
use rand::rngs::StdRng;
67+
6668
use super::*;
6769

6870
fn setup_primitive_arrays() -> (PrimitiveArray, PrimitiveArray, PrimitiveArray) {
69-
let mut rng = rand::rngs::StdRng::seed_from_u64(0);
71+
let mut rng = StdRng::seed_from_u64(0);
7072
let uint_array =
7173
PrimitiveArray::from_iter((0..NUM_VALUES).map(|_| rng.random_range(42u32..256)));
7274
let int_array = cast(uint_array.as_ref(), PType::I32.into())
@@ -113,7 +115,7 @@ mod setup {
113115
/// Create Dict <- VarBinView encoding tree for strings with BitPacked codes
114116
#[allow(clippy::cast_possible_truncation)]
115117
pub fn dict_varbinview_string() -> ArrayRef {
116-
let mut rng = rand::rngs::StdRng::seed_from_u64(42);
118+
let mut rng = StdRng::seed_from_u64(42);
117119

118120
// Create unique values (0.005% uniqueness = 50 unique strings)
119121
let num_unique = ((NUM_VALUES as f64) * 0.00005) as usize;
@@ -147,7 +149,7 @@ mod setup {
147149
/// Create RunEnd <- FoR <- BitPacked encoding tree for u32
148150
#[allow(clippy::cast_possible_truncation)]
149151
pub fn runend_for_bp_u32() -> ArrayRef {
150-
let mut rng = rand::rngs::StdRng::seed_from_u64(42);
152+
let mut rng = StdRng::seed_from_u64(42);
151153
// Create data with runs of repeated values
152154
let mut values = Vec::with_capacity(NUM_VALUES as usize);
153155
let mut current_value = rng.random_range(0u32..100);
@@ -189,7 +191,7 @@ mod setup {
189191
/// Create Dict <- FSST <- VarBin encoding tree for strings
190192
#[allow(clippy::cast_possible_truncation)]
191193
pub fn dict_fsst_varbin_string() -> ArrayRef {
192-
let mut rng = rand::rngs::StdRng::seed_from_u64(43);
194+
let mut rng = StdRng::seed_from_u64(43);
193195

194196
// Create unique values (1% uniqueness = 10,000 unique strings)
195197
let num_unique = ((NUM_VALUES as f64) * 0.01) as usize;
@@ -221,7 +223,7 @@ mod setup {
221223
/// Compress the VarBin offsets inside FSST with BitPacked
222224
#[allow(clippy::cast_possible_truncation)]
223225
pub fn dict_fsst_varbin_bp_string() -> ArrayRef {
224-
let mut rng = rand::rngs::StdRng::seed_from_u64(45);
226+
let mut rng = StdRng::seed_from_u64(45);
225227

226228
// Create unique values (1% uniqueness = 10,000 unique strings)
227229
let num_unique = ((NUM_VALUES as f64) * 0.01) as usize;
@@ -276,7 +278,7 @@ mod setup {
276278
/// Create DateTimeParts <- FoR <- BitPacked encoding tree
277279
pub fn datetime_for_bp() -> ArrayRef {
278280
// Create timestamp data (microseconds since epoch)
279-
let mut rng = rand::rngs::StdRng::seed_from_u64(123);
281+
let mut rng = StdRng::seed_from_u64(123);
280282
let base_timestamp = 1_600_000_000_000_000i64; // Sept 2020 in microseconds
281283
let timestamps: Vec<i64> = (0..NUM_VALUES)
282284
.map(|_| base_timestamp + rng.random_range(0..86_400_000_000)) // Random times within a day

vortex/benches/pipeline.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
use divan::Bencher;
118118
use fastlanes::BitPacking;
119119
use rand::Rng;
120+
use rand::SeedableRng;
121+
use rand::rngs::StdRng;
120122
use vortex_alp::ALPFloat;
121123
use vortex_alp::Exponents;
122124
use vortex_error::vortex_panic;
@@ -256,7 +258,7 @@ fn setup(size: usize) -> (InputData, BenchmarkBuffers) {
256258
fn create_random_values(len: usize) -> Vec<f32> {
257259
assert!(len.is_multiple_of(N));
258260

259-
let mut rng = rand::rng();
261+
let mut rng = StdRng::seed_from_u64(0);
260262
(0..len)
261263
.map(|_| rng.random_range(0..1024))
262264
.map(|x| x as f32 / 100.0)

vortex/benches/single_encoding_throughput.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use mimalloc::MiMalloc;
1111
use rand::Rng;
1212
use rand::SeedableRng;
1313
use rand::prelude::IndexedRandom;
14+
use rand::rngs::StdRng;
1415
use vortex::IntoArray;
1516
use vortex::ToCanonical;
1617
use vortex::arrays::PrimitiveArray;
@@ -55,7 +56,7 @@ macro_rules! with_counter {
5556

5657
// Setup functions
5758
fn setup_primitive_arrays() -> (PrimitiveArray, PrimitiveArray, PrimitiveArray) {
58-
let mut rng = rand::rngs::StdRng::seed_from_u64(0);
59+
let mut rng = StdRng::seed_from_u64(0);
5960
let uint_array =
6061
PrimitiveArray::from_iter((0..NUM_VALUES).map(|_| rng.random_range(42u32..256)));
6162
let int_array = cast(uint_array.as_ref(), PType::I32.into())
@@ -69,7 +70,7 @@ fn setup_primitive_arrays() -> (PrimitiveArray, PrimitiveArray, PrimitiveArray)
6970

7071
#[allow(clippy::cast_possible_truncation)]
7172
fn gen_varbin_words(len: usize, uniqueness: f64) -> Vec<String> {
72-
let mut rng = rand::rng();
73+
let mut rng = StdRng::seed_from_u64(0);
7374
let uniq_cnt = (len as f64 * uniqueness) as usize;
7475
let dict: Vec<String> = (0..uniq_cnt)
7576
.map(|_| {

0 commit comments

Comments
 (0)