diff options
| author | tv <tv@krebsco.de> | 2026-11-05 00:41:07 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-05 00:41:07 +0100 |
| commit | 4bb6282d6c439c40bceb3024afbc875f14aa4a9b (patch) | |
| tree | 7fb3b948ebb85985294deb2eb924bc24a19f3584 | |
| parent | 52e307d7b95dda735d1afbc4fe2dcffaa87512a4 (diff) | |
bench mycelium round trips
| -rw-r--r-- | docs/development.md | 5 | ||||
| -rw-r--r-- | src/simtest/bench.rs | 32 |
2 files changed, 35 insertions, 2 deletions
diff --git a/docs/development.md b/docs/development.md index 1771539..2ed15f6 100644 --- a/docs/development.md +++ b/docs/development.md @@ -21,8 +21,9 @@ The benchmarks are ignored tests named `bench_*`: the document's (writes and syn messages, `document/bench.rs`), the remakes' replay (`remake/bench.rs`), and what passing changes on costs over the simulated network (`simtest/bench.rs`: messages and bytes per write by kind, propagation delays, for a full mesh, a writer behind NAT, two -transports, partial meshes of 50 and 100 nodes, lossy links, a member away for a -while, and members joining during the writes; several minutes, or one scenario alone +transports, partial meshes of 50 and 100 nodes, lossy links (with delays at random, +and with Mycelium's round trips, each link its own), a member away for a while, and +members joining during the writes; several minutes, or one scenario alone with `BENCH_SCENARIO`, part of its name: `BENCH_SCENARIO=NAT`; all at once with `BENCH_PARALLEL=1`, faster on many cores, though sharing them makes delays come out somewhat higher; and in `bench_bridge`, large values from a writer on a fast transport diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index d5ca624..06b557e 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -105,6 +105,28 @@ fn lossy(sim: &Sim, _: &[String]) { }); } +/// As `lossy`, but each link with a latency of its own, as over Mycelium: round trips +/// from 20 to 250 ms, each message within a fifth of its link's. So what the uniform +/// 50–500 ms of `lossy` gives that real links don't: messages on one link overtake each +/// other only within the jitter, and the fast links to a node are fast every time. +fn mycelium_like(sim: &Sim, ids: &[String]) { + let mut rng = crate::testrand::Rng::new(7); + for (i, from) in ids.iter().enumerate() { + for to in &ids[i + 1..] { + let rtt_ms = 20.0 + rng.next_f64() * 230.0; + let half = Duration::from_secs_f64(rtt_ms / 2.0 / 1000.0); + let link = LinkParams { + loss: 0.02, + duplicate: 0.01, + delay: (half * 4 / 5, half * 6 / 5), + ..LinkParams::default() + }; + sim.net.set_link(from, to, link.clone()); + sim.net.set_link(to, from, link); + } + } +} + const SCENARIOS: &[Scenario] = &[ Scenario { name: "full mesh, 13 nodes", @@ -178,6 +200,16 @@ const SCENARIOS: &[Scenario] = &[ away: None, joining: 5, }, + // Last, so the others keep their seeds. + Scenario { + name: "partial mesh, lossy links with Mycelium's round trips, 50 nodes", + nodes: 50, + on: sim_only, + net: mycelium_like, + writer: 1, + away: None, + joining: 0, + }, ]; #[tokio::test(flavor = "multi_thread", worker_threads = 16)] |
