diff options
| author | tv <tv@krebsco.de> | 2026-11-06 05:33:59 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-06 05:33:59 +0100 |
| commit | 545a8848a97b77899c96a8047f98d7e2f1931dab (patch) | |
| tree | 8c32be86370e36ac6afe05e2455f6ecd0d1fcd8c | |
| parent | 003207f94830fed0def25b49a7e6fc61655ec934 (diff) | |
bench waits for recorded links
| -rw-r--r-- | src/simtest/bench.rs | 17 | ||||
| -rw-r--r-- | src/swarm/working_links.rs | 26 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index d8c08e2..2a96007 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -502,6 +502,23 @@ async fn run(seed: u64, scenario: &'static Scenario) -> String { ) .await; sim.wait_converged(all, SETTLE).await; + // The links that don't work recorded (`swarm::working_links`, after their hold), so + // the trees are built over the links that do from the first write: every node + // checked since, with nothing awaiting its hold. Lossy links may keep some waiting: + // not for longer than settling. + let checks: Vec<u64> = all + .iter() + .map(|node| crate::swarm::working_links::settled(node).0) + .collect(); + let recording = Instant::now(); + while recording.elapsed() < SETTLE + && !all.iter().zip(&checks).all(|(node, before)| { + let (checks, settled) = crate::swarm::working_links::settled(node); + checks > *before && settled + }) + { + tokio::time::sleep(Duration::from_secs(1)).await; + } // 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. diff --git a/src/swarm/working_links.rs b/src/swarm/working_links.rs index 621ea6c..6f07375 100644 --- a/src/swarm/working_links.rs +++ b/src/swarm/working_links.rs @@ -43,6 +43,17 @@ const UP_FOR: u32 = 1; #[derive(Default)] pub(crate) struct Pending { since: HashMap<String, Instant>, + /// Checks done (`check`), for the benchmark to wait for one (`settled`). + #[cfg(test)] + checks: u64, +} + +/// How many checks were done, and whether none of our links differs from our record +/// (nothing awaits its hold). +#[cfg(test)] +pub(crate) fn settled(state: &AppState) -> (u64, bool) { + let pending = state.working_links.lock_or_recover(); + (pending.checks, pending.since.is_empty()) } /// With the peer worker's periodic pass (every 5 s): whom we reach now, against the @@ -76,13 +87,14 @@ pub(crate) async fn check(state: &AppState) { let replica = state.doc.read().await; members::links(&replica.doc, &me) }; - let next = decide( - &mut state.working_links.lock_or_recover(), - &recorded, - &links, - now, - state.timing.keepalive, - ); + let next = { + let mut pending = state.working_links.lock_or_recover(); + #[cfg(test)] + { + pending.checks += 1; + } + decide(&mut pending, &recorded, &links, now, state.timing.keepalive) + }; if next == recorded { return; } |
