Skip to content

Commit

Permalink
First round of review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Oct 23, 2024
1 parent 7410099 commit c0b88f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
22 changes: 16 additions & 6 deletions framework/summary_model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, usize>,
pub assigned_behaviours: HashMap<String, usize>,
/// Environment variables set for the run
///
/// This won't capture all environment variables. Just the ones that the runner is aware of or
Expand All @@ -71,7 +71,7 @@ impl RunSummary {
started_at: i64,
run_duration: Option<u64>,
peer_count: usize,
behaviours: HashMap<String, usize>,
assigned_behaviours: HashMap<String, usize>,
wind_tunnel_version: String,
) -> Self {
Self {
Expand All @@ -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,
}
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion scenarios/dht_sync_lag/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions scenarios/remote_call_rate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions summariser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit c0b88f7

Please sign in to comment.