From c0b88f7eb65e722d0493d1f390c644162c7581ef Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Wed, 23 Oct 2024 15:08:23 +0100 Subject: [PATCH] First round of review changes --- framework/summary_model/src/lib.rs | 22 ++++++++++++++++------ scenarios/dht_sync_lag/src/main.rs | 2 +- scenarios/remote_call_rate/src/main.rs | 4 ++-- summariser/src/main.rs | 2 ++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/framework/summary_model/src/lib.rs b/framework/summary_model/src/lib.rs index f1906d9..583209d 100644 --- a/framework/summary_model/src/lib.rs +++ b/framework/summary_model/src/lib.rs @@ -51,7 +51,7 @@ pub struct RunSummary { /// Note: This is only meaningful for single-conductor tests with the standard Wind Tunnel runner /// or with the TryCP runner. In general, each node only sees the roles it was assigned and not /// the roles that were assigned across the network. - pub behaviours: HashMap, + pub assigned_behaviours: HashMap, /// Environment variables set for the run /// /// This won't capture all environment variables. Just the ones that the runner is aware of or @@ -71,7 +71,7 @@ impl RunSummary { started_at: i64, run_duration: Option, peer_count: usize, - behaviours: HashMap, + assigned_behaviours: HashMap, wind_tunnel_version: String, ) -> Self { Self { @@ -81,7 +81,7 @@ impl RunSummary { run_duration, peer_count, peer_end_count: 0, - behaviours, + assigned_behaviours, env: HashMap::with_capacity(0), wind_tunnel_version, } @@ -97,21 +97,31 @@ impl RunSummary { self.env.insert(key, value); } + /// Computer a fingerprint for this run summary + /// + /// The fingerprint is intended to uniquely identify the configuration used to run the scenario. + /// It uses the + /// - Run duration + /// - Assigned behaviours + /// - Selected environment variables + /// - Wind Tunnel version + /// + /// The fingerprint is computed using SHA3-256. pub fn fingerprint(&self) -> String { let mut hasher = sha3::Sha3_256::new(); if let Some(run_duration) = self.run_duration { Digest::update(&mut hasher, run_duration.to_le_bytes()); } - self.behaviours + self.assigned_behaviours .iter() - .sorted_by_key(|(k, _)| (*k).clone()) + .sorted_by_key(|(k, _)| k.to_owned()) .for_each(|(k, v)| { Digest::update(&mut hasher, k.as_bytes()); Digest::update(&mut hasher, v.to_le_bytes()); }); self.env .iter() - .sorted_by_key(|(k, _)| (*k).clone()) + .sorted_by_key(|(k, _)| k.to_owned()) .for_each(|(k, v)| { Digest::update(&mut hasher, k.as_bytes()); Digest::update(&mut hasher, v.as_bytes()); diff --git a/scenarios/dht_sync_lag/src/main.rs b/scenarios/dht_sync_lag/src/main.rs index c80b79b..d653f0e 100644 --- a/scenarios/dht_sync_lag/src/main.rs +++ b/scenarios/dht_sync_lag/src/main.rs @@ -82,7 +82,7 @@ fn agent_behaviour_record_lag( .unwrap() .as_micros() - timed_entry.created_at.as_micros() as u128) as f64 - / 10e6; + / 1e6; let metric = metric .with_tag("agent", agent_pub_key.clone()) .with_field("value", lag_s); diff --git a/scenarios/remote_call_rate/src/main.rs b/scenarios/remote_call_rate/src/main.rs index 10e6964..e3e582b 100644 --- a/scenarios/remote_call_rate/src/main.rs +++ b/scenarios/remote_call_rate/src/main.rs @@ -101,8 +101,8 @@ fn agent_behaviour( .decode() .map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; - let dispatch_time_s = response.request_value.as_micros() as f64 / 10e6; - let receive_time_s = response.value.as_micros() as f64 / 10e6; + let dispatch_time_s = response.request_value.as_micros() as f64 / 1e6; + let receive_time_s = response.value.as_micros() as f64 / 1e6; reporter.add_custom( ReportMetric::new("remote_call_dispatch") diff --git a/summariser/src/main.rs b/summariser/src/main.rs index b96b1c0..5c52505 100644 --- a/summariser/src/main.rs +++ b/summariser/src/main.rs @@ -10,6 +10,8 @@ pub(crate) mod filter; async fn main() -> anyhow::Result<()> { env_logger::init(); + println!("{}", 1e6); + #[cfg(feature = "test_data")] log::info!("Test data generation enabled");