Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Closed
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"ratelimit",
"ringlog",
"switchboard",
"waterfall",
]

[profile.bench]
Expand Down
6 changes: 3 additions & 3 deletions awaken/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awaken"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
license = "Apache-2.0"
authors = ["Brian Martin <brian@pelikan.io>"]
Expand All @@ -9,7 +9,7 @@ homepage = "https://github.com/pelikan-io/rustcommon"
repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
mio = "0.8.11"
mio = "1.1"

[target.'cfg(target_os = "linux")'.dependencies]
libc = "0.2.139"
libc = "0.2.183"
6 changes: 3 additions & 3 deletions clocksource/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clocksource"
version = "0.8.2"
version = "0.8.3"
authors = ["Brian Martin <brian@pelikan.io>"]
edition = "2021"
description = "Library for times and durations with fixed-size representations"
Expand All @@ -9,8 +9,8 @@ homepage = "https://github.com/pelikan-io/rustcommon"
repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
libc = "0.2.147"
time = { version = "0.3.36", features = ["formatting"] }
libc = "0.2.183"
time = { version = "0.3.47", features = ["formatting"] }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["ntdef", "profileapi", "sysinfoapi"] }
12 changes: 6 additions & 6 deletions histogram/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "histogram"
version = "0.11.4"
version = "0.11.5"
edition = "2021"
authors = ["Brian Martin <brian@pelikan.io>"]
license = "MIT OR Apache-2.0"
Expand All @@ -9,13 +9,13 @@ homepage = "https://github.com/pelikan-io/rustcommon"
repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
schemars = { version = "0.8", optional = true }
serde = { version = "1.0.144", features = ["derive"], optional = true }
thiserror = "1.0.47"
schemars = { version = "1.2", optional = true }
serde = { version = "1.0.228", features = ["derive"], optional = true }
thiserror = "2.0"

[dev-dependencies]
criterion = "0.5.1"
rand = "0.8.5"
criterion = "0.8"
rand = "0.10"

[features]
schemars = ["dep:schemars", "serde"]
Expand Down
6 changes: 3 additions & 3 deletions histogram/src/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl From<&Histogram> for SparseHistogram {

#[cfg(test)]
mod tests {
use rand::Rng;
use rand::RngExt;
use std::collections::HashMap;

use super::*;
Expand Down Expand Up @@ -506,11 +506,11 @@ mod tests {
#[test]
fn downsample() {
let mut histogram = Histogram::new(8, 32).unwrap();
let mut rng = rand::thread_rng();
let mut rng = rand::rng();

// Generate 10,000 values to store in a sorted array and a histogram
for _ in 0..10000 {
let v: u64 = rng.gen_range(1..2_u64.pow(histogram.config.max_value_power() as u32));
let v: u64 = rng.random_range(1..2_u64.pow(histogram.config.max_value_power() as u32));
let _ = histogram.increment(v);
}

Expand Down
8 changes: 4 additions & 4 deletions histogram/src/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl Histogram {
}

/// Returns an interator across the histogram.
pub fn iter(&self) -> Iter {
pub fn iter(&self) -> Iter<'_> {
Iter {
index: 0,
histogram: self,
Expand Down Expand Up @@ -315,7 +315,7 @@ impl From<&SparseHistogram> for Histogram {
#[cfg(test)]
mod tests {
use super::*;
use rand::Rng;
use rand::RngExt;

#[cfg(target_pointer_width = "64")]
#[test]
Expand Down Expand Up @@ -408,11 +408,11 @@ mod tests {
fn downsample() {
let mut histogram = Histogram::new(8, 32).unwrap();
let mut vals: Vec<u64> = Vec::with_capacity(10000);
let mut rng = rand::thread_rng();
let mut rng = rand::rng();

// Generate 10,000 values to store in a sorted array and a histogram
for _ in 0..vals.capacity() {
let v: u64 = rng.gen_range(1..2_u64.pow(histogram.config.max_value_power() as u32));
let v: u64 = rng.random_range(1..2_u64.pow(histogram.config.max_value_power() as u32));
vals.push(v);
let _ = histogram.increment(v);
}
Expand Down
6 changes: 3 additions & 3 deletions ratelimit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ratelimit"
version = "0.10.0"
version = "0.10.1"
authors = ["Brian Martin <brian@pelikan.io>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -10,5 +10,5 @@ repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
clocksource = { version = "0.8.0", path = "../clocksource" }
parking_lot = "0.12.1"
thiserror = "1.0.40"
parking_lot = "0.12.5"
thiserror = "2.0"
6 changes: 3 additions & 3 deletions ringlog/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ringlog"
version = "0.8.0"
version = "0.8.1"
edition = "2021"
license = "Apache-2.0"
authors = ["Brian Martin <brian@pelikan.io>"]
Expand All @@ -9,9 +9,9 @@ homepage = "https://github.com/pelikan-io/rustcommon"
repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
ahash = "0.8.0"
ahash = "0.8.12"
clocksource = { version = "0.8.0", path = "../clocksource" }
log = { version = "0.4.17", features = ["std"] }
log = { version = "0.4.29", features = ["std"] }
metriken = { version = "0.7.0", optional = true }
mpmc = "0.1.6"

Expand Down
14 changes: 7 additions & 7 deletions switchboard/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "switchboard"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
license = "Apache-2.0"
authors = ["Brian Martin <brian@pelikan.io>"]
Expand All @@ -9,11 +9,11 @@ homepage = "https://github.com/pelikan-io/rustcommon"
repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
awaken = { version = "0.2.0", path = "../awaken" }
crossbeam-queue = "0.3.8"
rand = "0.8.5"
rand_chacha = "0.3.1"
thiserror = "1.0"
awaken = { version = "0.3.0", path = "../awaken" }
crossbeam-queue = "0.3.12"
rand = "0.10"
rand_chacha = "0.10"
thiserror = "2.0"

[dev-dependencies]
mio = { version = "0.8.11", features = ["os-poll"]}
mio = { version = "1.1", features = ["os-poll"]}
17 changes: 8 additions & 9 deletions switchboard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
pub use awaken::Waker;

use crossbeam_queue::*;
use rand::distributions::Uniform;
use rand::Rng as RandRng;
use rand::SeedableRng;
use rand::distr::Uniform;
use rand::{RngExt, SeedableRng};
use rand_chacha::ChaCha20Rng;
use std::sync::Arc;
use thiserror::Error;
Expand Down Expand Up @@ -176,8 +175,8 @@ impl<T, U> Queues<T, U> {
a.push(Queues {
senders: a_tx.clone(),
receiver,
rng: ChaCha20Rng::from_entropy(),
distr: Uniform::new(0, a_tx.len()),
rng: ChaCha20Rng::from_rng(&mut rand::rng()),
distr: Uniform::new(0, a_tx.len()).unwrap(),
id,
})
}
Expand All @@ -186,8 +185,8 @@ impl<T, U> Queues<T, U> {
b.push(Queues {
senders: b_tx.clone(),
receiver,
rng: ChaCha20Rng::from_entropy(),
distr: Uniform::new(0, b_tx.len()),
rng: ChaCha20Rng::from_rng(&mut rand::rng()),
distr: Uniform::new(0, b_tx.len()).unwrap(),
id,
})
}
Expand Down Expand Up @@ -223,7 +222,7 @@ impl<T, U> Queues<T, U> {
sender: self.id,
inner: item,
})
.map_err(|e| e.into_inner())
.map_err(|e: TrackedItem<T>| e.into_inner())
}

/// Try to send a single item to any receiver. Uses a uniform random
Expand All @@ -240,7 +239,7 @@ impl<T, U> Queues<T, U> {
sender: self.id,
inner: item,
})
.map_err(|e| e.into_inner())
.map_err(|e: TrackedItem<T>| e.into_inner())
}

/// Wake any remote receivers which have been sent items since the last time
Expand Down
17 changes: 8 additions & 9 deletions waterfall/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "waterfall"
version = "0.8.2"
version = "0.9.0"
authors = ["Brian Martin <brian@pelikan.io>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -9,14 +9,13 @@ homepage = "https://github.com/pelikan-io/rustcommon"
repository = "https://github.com/pelikan-io/rustcommon"

[dependencies]
clocksource = { version = "0.6.0" }
clocksource = { version = "0.8.0", path = "../clocksource" }
dejavu = "2.37.0"
image = "0.24.3"
log = "0.4.17"
heatmap = { version = "0.7.1", path = "../heatmap" }
histogram = { version = "0.7.1" }
rusttype = "0.9.2"
histogram = { version = "0.11.5", path = "../histogram" }
image = "0.25"
log = "0.4.29"
rusttype = "0.9.3"

[dev-dependencies]
rand = "0.8.5"
rand_distr = "0.4.3"
rand = "0.10"
rand_distr = "0.6"
39 changes: 16 additions & 23 deletions waterfall/examples/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

use heatmap::*;
use rand::thread_rng;
use clocksource::precise::Duration;
use rand::RngExt;
use rand_distr::*;
use std::time::Instant;
use waterfall::*;

fn main() {
Expand All @@ -31,46 +32,38 @@ pub enum Shape {
}

pub fn simulate(shape: Shape) {
let duration = Duration::from_secs(10);
let run_duration = std::time::Duration::from_secs(10);
println!(
"Simulating for {:?} distribution for {:?} seconds",
shape,
duration.as_secs_f64()
run_duration.as_secs_f64()
);

let heatmap = Heatmap::new(
0,
10,
30,
Duration::from_secs(10),
Duration::from_millis(250),
None,
None,
)
.unwrap();
let mut heatmap =
Heatmap::new(0, 30, Duration::from_secs(10), Duration::from_millis(250)).unwrap();

let cauchy = Cauchy::new(500_000.0, 2_000.00).unwrap();
let normal = Normal::new(200_000.0, 100_000.0).unwrap();
let uniform = Uniform::new_inclusive(10_000.0, 200_000.0);
let uniform = rand_distr::Uniform::new(10_000.0, 200_000.0).unwrap();
let triangular = Triangular::new(1.0, 200_000.0, 50_000.0).unwrap();
let gamma = Gamma::new(2.0, 2.0).unwrap();

let mut rng = thread_rng();
let mut rng = rand::rng();
let start = Instant::now();
loop {
if start.elapsed() >= duration {
if start.elapsed() >= run_duration {
break;
}
let value: f64 = match shape {
Shape::Cauchy => cauchy.sample(&mut rng),
Shape::Normal => normal.sample(&mut rng),
Shape::Uniform => uniform.sample(&mut rng),
Shape::Triangular => triangular.sample(&mut rng),
Shape::Gamma => gamma.sample(&mut rng) * 100_000.0,
Shape::Cauchy => rng.sample(cauchy),
Shape::Normal => rng.sample(normal),
Shape::Uniform => rng.sample(uniform),
Shape::Triangular => rng.sample(triangular),
Shape::Gamma => rng.sample(gamma) * 100_000.0,
};
let value = value.floor() as u64;
if value != 0 {
let _ = heatmap.increment(Instant::now(), value, 1);
let _ = heatmap.increment(clocksource::precise::Instant::now(), value, 1);
}
}

Expand Down
Loading
Loading