diff --git a/Cargo.lock b/Cargo.lock index 10a0166d..44e2a4a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1925,6 +1925,7 @@ dependencies = [ "mio 0.8.8", "momento", "net", + "once_cell", "paste", "protocol-memcache", "protocol-ping", diff --git a/Cargo.toml b/Cargo.toml index 356a2bb3..723b50a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ momento = "0.31.0" metriken = { git = "https://github.com/brayniac/rustcommon", branch = "metriken-histograms" } mio = "0.8.8" net = { git = "https://github.com/pelikan-io/pelikan" } +once_cell = "1.18.0" paste = "1.0.14" protocol-memcache = { git = "https://github.com/pelikan-io/pelikan" } protocol-ping = { git = "https://github.com/pelikan-io/pelikan" } diff --git a/src/main.rs b/src/main.rs index e8447ce2..0df46361 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use crate::clients::launch_clients; use crate::pubsub::launch_pubsub; use crate::workload::{launch_workload, Generator}; @@ -30,10 +31,12 @@ use metrics::*; type Instant = clocksource::Instant>; type UnixInstant = clocksource::UnixInstant>; +type HistogramSnapshots = HashMap; + static RUNNING: AtomicBool = AtomicBool::new(true); -static SNAPSHOTS: Arc>>> = - Arc::new(RwLock::new(VecDeque::new())); +static SNAPSHOTS: Lazy>>> = + Lazy::new(|| Arc::new(RwLock::new(VecDeque::new()))); fn main() { // custom panic hook to terminate whole process after unwinding