From 87b7133c9db82c4db4238908481a2a848d171010 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 4 Nov 2026 23:48:02 +0100 Subject: benchmark bridge slow link --- src/simtest/bench.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index 426507b..ab1809d 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -664,9 +664,13 @@ const BRIDGE_WRITES: usize = 200; const BRIDGE_VALUE: usize = 256 * 1024; /// A hundred a second. const BRIDGE_EVERY: Duration = Duration::from_millis(10); +/// The slow transport, unless `BENCH_BRIDGE_SLOW_RATE` (MiB/s) and +/// `BENCH_BRIDGE_SLOW_RTT` (ms) say otherwise. +const BRIDGE_SLOW_RATE_MIB: u64 = 50; +const BRIDGE_SLOW_RTT_MS: u64 = 500; /// A writer on a fast transport (5 ms round trips, 1 GiB/s), a bridge on it and a slow -/// one (500 ms round trips, 50 MiB/s), and a node on the slow one alone: a writes 256 +/// one (500 ms round trips, 50 MiB/s, by default), and a node on the slow one alone: a writes 256 /// KiB values at 100 a second (25 MiB/s, a quarter of the fast link, half of the slow /// one), b passes them on to z. What z gets, as sync messages and as blobs (deltas), /// against what was written, and how late. @@ -674,19 +678,26 @@ const BRIDGE_EVERY: Duration = Duration::from_millis(10); #[ignore = "a benchmark: cargo benchmarks"] async fn bench_bridge() { println!(); - let writes = std::env::var("BENCH_BRIDGE_WRITES") - .ok() - .and_then(|writes| writes.parse().ok()) - .unwrap_or(BRIDGE_WRITES); + let env = |name: &str, default| { + std::env::var(name) + .ok() + .and_then(|value| value.parse().ok()) + .unwrap_or(default) + }; + let writes = env("BENCH_BRIDGE_WRITES", BRIDGE_WRITES as u64) as usize; + let slow_rate = env("BENCH_BRIDGE_SLOW_RATE", BRIDGE_SLOW_RATE_MIB); + let slow_rtt = env("BENCH_BRIDGE_SLOW_RTT", BRIDGE_SLOW_RTT_MS); let sim = Sim::with_identity(71); sim.net.set_default_link(LinkParams { delay: (Duration::from_micros(2_000), Duration::from_micros(3_000)), rate: Some(1 << 30), ..LinkParams::default() }); + // Half the round trip each way, give or take a twentieth. + let half = Duration::from_millis(slow_rtt / 2); sim.net_for("sim2").set_default_link(LinkParams { - delay: (Duration::from_millis(240), Duration::from_millis(260)), - rate: Some(50 << 20), + delay: (half - half / 20, half + half / 20), + rate: Some(slow_rate << 20), ..LinkParams::default() }); let timing = |config: &mut crate::node::NodeConfig| { @@ -752,7 +763,7 @@ async fn bench_bridge() { .map_or("beyond the last bucket".to_owned(), |ms| format!("{ms} ms")) }; println!( - "\nfast writer, bridge, slow node ({writes} values of {} KiB, {} a second)\n \ + "\nfast writer, bridge, slow node ({writes} values of {} KiB, {} a second; slow link {slow_rate} MiB/s, {slow_rtt} ms round trips)\n \ written: {:.1} MiB in {:.1} s; z converged {} ms after the last write\n \ b sent (to a and z): SYNC {} messages, {:.1} MiB; BLOB {} messages, {:.1} MiB\n \ z received: SYNC {} messages, {:.1} MiB; BLOB {} messages, {:.1} MiB: {:.2} times what was written\n \ -- cgit v1.3.1