Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ openssl = "0.10.72"
parse_duration = "2.1.1"
pin-project = "1.1"
plotters = { version = "0.3", default-features = false, features = ["line_series", "svg_backend", "full_palette"] }
rand = { version = "0.8", default-features = false, features = ["small_rng", "std"] }
rand_distr = "0.4"
rand = { version = "0.9.4", default-features = false, features = ["small_rng", "std", "thread_rng"] }
rand_distr = "0.5"
regex = "1.5"
rune = "0.13"
rust_decimal = "1.36"
Expand Down
3 changes: 2 additions & 1 deletion src/exec/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use crate::scripting::db_error::{DbError, DbErrorKind};
use crate::scripting::retry_error::handle_retry_error;
use crate::stats::latency::LatencyDistributionRecorder;
use crate::stats::session::SessionStats;
use rand::distributions::{Distribution, WeightedIndex};
use rand::distr::weighted::WeightedIndex;
use rand::distr::Distribution;
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use rune::alloc::clone::TryClone;
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/cql/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl Context {
preferred_datacenter,
preferred_rack,
data: Value::Object(Shared::new(Object::new()).unwrap()),
rng: rand::thread_rng(),
rng: rand::rng(),
}
}

Expand All @@ -372,7 +372,7 @@ impl Context {
preferred_rack: self.preferred_rack.clone(),
data: deserialized,
start_time: TryLock::new(*self.start_time.try_lock().unwrap()),
rng: rand::thread_rng(),
rng: rand::rng(),
})
}

Expand Down
10 changes: 5 additions & 5 deletions src/scripting/functions_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::scripting::rune_uuid::Uuid;
use crate::scripting::Resources;
use chrono::Utc;
use metrohash::MetroHash64;
use rand::distributions::Distribution;
use rand::distr::Distribution;
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use rand_distr::{Normal, Uniform};
use rune::macros::{quote, MacroContext, TokenStream};
use rune::parse::Parser;
use rune::runtime::{Function, Ref, VmError, VmResult};
use rune::{ast, vm_try, Value};
use statrs::distribution::{Normal, Uniform};
use std::collections::HashMap;
use std::fs::File;
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn normal(i: i64, mean: f64, std_dev: f64) -> VmResult<f64> {
#[rune::function]
pub fn normal_f32(i: i64, mean: f32, std_dev: f32) -> VmResult<f32> {
let mut rng = SmallRng::seed_from_u64(i as u64);
let distribution = vm_try!(
let distribution: Normal<f64> = vm_try!(
Normal::new(mean.into(), std_dev.into()).map_err(|e| VmError::panic(format!("{e}")))
);
VmResult::Ok(distribution.sample(&mut rng) as f32)
Expand All @@ -113,7 +113,7 @@ pub fn uniform(i: i64, min: f64, max: f64) -> VmResult<f64> {
#[rune::function]
pub fn blob(seed: i64, len: usize) -> Vec<u8> {
let mut rng = SmallRng::seed_from_u64(seed as u64);
(0..len).map(|_| rng.gen::<u8>()).collect()
(0..len).map(|_| rng.random::<u8>()).collect()
}

/// Generates random string of given length.
Expand All @@ -128,7 +128,7 @@ pub fn text(seed: i64, len: usize) -> String {
let mut rng = SmallRng::seed_from_u64(seed as u64);
(0..len)
.map(|_| {
let idx = rng.gen_range(0..charset.len());
let idx = rng.random_range(0..charset.len());
charset[idx]
})
.collect()
Expand Down
12 changes: 6 additions & 6 deletions src/stats/percentiles.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::stats::Mean;
use hdrhistogram::Histogram;
use rand::rngs::SmallRng;
use rand::{thread_rng, Rng, SeedableRng};
use rand::{Rng, SeedableRng};
use serde::{Deserialize, Serialize};
use statrs::statistics::Statistics;
use strum::{EnumCount, EnumIter, IntoEnumIterator};
Expand Down Expand Up @@ -98,7 +98,7 @@ impl Percentiles {
scale: f64,
effective_sample_size: u64,
) -> Percentiles {
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
let mut rng = SmallRng::from_rng(&mut rand::rng());

let mut samples: Vec<[f64; Percentile::COUNT]> = Vec::with_capacity(Self::POPULATION_SIZE);
for _ in 0..Self::POPULATION_SIZE {
Expand Down Expand Up @@ -174,8 +174,8 @@ mod test {
use crate::stats::percentiles::{Percentile, Percentiles};
use assert_approx_eq::assert_approx_eq;
use hdrhistogram::Histogram;
use rand::{thread_rng, Rng};
use statrs::distribution::Uniform;
use rand::Rng;
use rand_distr::Uniform;

#[test]
fn test_zero_error() {
Expand All @@ -193,11 +193,11 @@ mod test {
#[test]
fn test_min_max_error() {
let mut histogram = Histogram::<u64>::new(3).unwrap();
let d = Uniform::new(0.0, 1000.0).unwrap();
let d: Uniform<f64> = Uniform::new(0.0, 1000.0).unwrap();
const N: usize = 100000;
for _ in 0..N {
histogram
.record(thread_rng().sample(d).round() as u64)
.record(rand::rng().sample(d).round() as u64)
.unwrap();
}

Expand Down
10 changes: 5 additions & 5 deletions src/stats/timeseries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod test {
let mut estimator = TimeSeriesStats::default();
const N: u64 = 1000;
for _ in 0..N {
estimator.record(rng.gen(), 1.0);
estimator.record(rng.random(), 1.0);
}
assert_gt!(estimator.effective_sample_size(), N / 2);
assert_le!(estimator.effective_sample_size(), N);
Expand All @@ -249,7 +249,7 @@ mod test {
let mut rng = SmallRng::seed_from_u64(1);
let mut estimator = TimeSeriesStats::default();
for _ in 0..n {
let v = rng.gen();
let v = rng.random();
for _ in 0..cluster_size {
estimator.record(v, 1.0);
}
Expand All @@ -263,7 +263,7 @@ mod test {
const COUNT: usize = 1000;
let mut rng = SmallRng::seed_from_u64(1);
let data: Vec<_> = (0..COUNT)
.map(|i| 0.001 * i as f64 + rng.gen::<f64>())
.map(|i| 0.001 * i as f64 + rng.random::<f64>())
.collect();
let mut est = Stats::default();
data.iter().for_each(|x| est.record(*x, 1.0));
Expand All @@ -286,8 +286,8 @@ mod test {
const COUNT: usize = 10000;
let mut rng = SmallRng::seed_from_u64(1);
let mut data = Vec::new();
data.extend((0..COUNT / 2).map(|_| rng.gen::<f64>()));
data.extend((0..COUNT / 2).map(|_| rng.gen::<f64>() + 0.2));
data.extend((0..COUNT / 2).map(|_| rng.random::<f64>()));
data.extend((0..COUNT / 2).map(|_| rng.random::<f64>() + 0.2));

let mut est = TimeSeriesStats::default();
data.iter().for_each(|x| est.record(*x, 1.0));
Expand Down
Loading