aboutsummaryrefslogtreecommitdiffstats
path: root/src/simtest
diff options
context:
space:
mode:
Diffstat (limited to 'src/simtest')
-rw-r--r--src/simtest/bench.rs35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs
index d80190d..babd8e9 100644
--- a/src/simtest/bench.rs
+++ b/src/simtest/bench.rs
@@ -5,8 +5,9 @@
//! that the nodes converge.
//!
//! Each scenario starts its swarm and waits until it has settled (every member known,
-//! the same heads, then no sync message for a while), then measures a quiet phase (no
-//! writes), then each workload: 100 writes at 5 a second, and until every node has
+//! the same heads, then sync messages no fewer in one half of the quiet phase than in
+//! the one before), those two halves being the quiet phase (no writes), then each
+//! workload: 100 writes at 5 a second, and until every node has
//! them. What a workload sent is shown as it is, beside what the quiet phase sent in as
//! long: not taken off, since writes make keepalives unneeded (a pair that exchanges
//! anything needs none), so the quiet phase's count isn't part of a workload's.
@@ -30,8 +31,10 @@ const WRITE_EVERY: Duration = Duration::from_millis(200);
/// Longer than the tests' (`simtest::KEEPALIVE`), so that keepalives don't drown what
/// the writes cost; as long as the relay tests'.
const KEEPALIVE: Duration = Duration::from_secs(5);
-/// The quiet phase: long enough to see the keepalives' rate.
+/// The quiet phase: long enough to see the keepalives' rate (a STATUS every third, 15 s).
const QUIET: Duration = Duration::from_secs(20);
+/// Only the scenarios whose names contain this, if set: `BENCH_SCENARIO=NAT`.
+const ONLY: &str = "BENCH_SCENARIO";
const SETTLE: Duration = Duration::from_secs(180);
/// How the swarm is made.
@@ -136,8 +139,11 @@ const SCENARIOS: &[Scenario] = &[
async fn bench_propagation() {
// Past the test harness's `test … ...`, so each report is on a line of its own.
println!();
+ let only = std::env::var(ONLY).unwrap_or_default();
for (seed, scenario) in (70..).zip(SCENARIOS) {
- run(seed, scenario).await;
+ if scenario.name.contains(&only) {
+ run(seed, scenario).await;
+ }
}
}
@@ -267,21 +273,22 @@ async fn run(seed: u64, scenario: &Scenario) {
)
.await;
sim.wait_converged(all, SETTLE).await;
- // Neighbours chosen, handshakes done, what joining set off over: no sync message for
- // two keepalives (registrations and alive stamps still pass for a while).
+ // Neighbours chosen, handshakes done, what joining set off over: sync messages no
+ // fewer in a half of the quiet phase than in the one before (some go on for good:
+ // alive stamps, registrations). Those two halves are the quiet phase.
let settling = Instant::now();
+ let mut halves = vec![Totals::of(&nodes)];
loop {
- let before = Totals::of(&nodes);
- tokio::time::sleep(KEEPALIVE * 2).await;
- let after = Totals::of(&nodes);
- if after.sent.sync.messages == before.sent.sync.messages || settling.elapsed() > SETTLE {
+ tokio::time::sleep(QUIET / 2).await;
+ halves.push(Totals::of(&nodes));
+ let count = |i: usize| halves[i + 1].sent.sync.messages - halves[i].sent.sync.messages;
+ let n = halves.len();
+ if (n >= 3 && count(n - 2) >= count(n - 3)) || settling.elapsed() > SETTLE {
break;
}
}
-
- let before = Totals::of(&nodes);
- tokio::time::sleep(QUIET).await;
- let quiet = (before, Totals::of(&nodes));
+ let n = halves.len();
+ let quiet = (halves[n.saturating_sub(3)], halves[n - 1]);
println!(
"\n{} ({} writes at {} a second each)",