From 02884c15580d1e6d498d7908dfc833094a368144 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 4 Nov 2026 23:52:09 +0100 Subject: benchmark bridge fast link --- src/simtest/bench.rs | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'src/simtest/bench.rs') diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index ab1809d..d5ca624 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -664,13 +664,16 @@ 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. +/// The fast transport and the slow one, unless `BENCH_BRIDGE_FAST_RATE`, +/// `BENCH_BRIDGE_SLOW_RATE` (MiB/s) and `BENCH_BRIDGE_FAST_RTT`, `BENCH_BRIDGE_SLOW_RTT` +/// (ms) say otherwise. +const BRIDGE_FAST_RATE_MIB: u64 = 1024; +const BRIDGE_FAST_RTT_MS: u64 = 5; 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, by default), and a node on the slow one alone: a writes 256 +/// A writer on a fast transport (5 ms round trips, 1 GiB/s, by default), 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 /// 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. @@ -685,21 +688,23 @@ async fn bench_bridge() { .unwrap_or(default) }; let writes = env("BENCH_BRIDGE_WRITES", BRIDGE_WRITES as u64) as usize; + let fast_rate = env("BENCH_BRIDGE_FAST_RATE", BRIDGE_FAST_RATE_MIB); + let fast_rtt = env("BENCH_BRIDGE_FAST_RTT", BRIDGE_FAST_RTT_MS); 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: (half - half / 20, half + half / 20), - rate: Some(slow_rate << 20), - ..LinkParams::default() - }); + // Half the round trip each way, give or take a fifth. + let link = |rate_mib: u64, rtt_ms: u64| { + let half = Duration::from_micros(rtt_ms * 500); + LinkParams { + delay: (half - half / 5, half + half / 5), + rate: Some(rate_mib << 20), + ..LinkParams::default() + } + }; + sim.net.set_default_link(link(fast_rate, fast_rtt)); + sim.net_for("sim2") + .set_default_link(link(slow_rate, slow_rtt)); let timing = |config: &mut crate::node::NodeConfig| { config.timing = Timing::new(KEEPALIVE, SYNC_REPLY_TIMEOUT, DELIVERY_LIMIT); config.neighbours_k = 12; @@ -763,7 +768,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; slow link {slow_rate} MiB/s, {slow_rtt} ms round trips)\n \ + "\nfast writer, bridge, slow node ({writes} values of {} KiB, {} a second; fast link {fast_rate} MiB/s, {fast_rtt} ms round trips; 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