diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/document/sync.rs | 8 | ||||
| -rw-r--r-- | src/simtest/bench.rs | 24 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/document/sync.rs b/src/document/sync.rs index 179df78..7123138 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -615,6 +615,14 @@ impl SyncSession { hashes.len() } + /// How many changes count as sent to the peer (`sent_hashes`): kept until the peer's + /// message says it has them (Automerge), or forgotten when a send fails or its + /// answer is overdue. + #[cfg(test)] + pub(crate) fn sent_hashes_len(&self) -> usize { + self.state.sent_hashes.len() + } + /// Of the changes in `doc` beyond `from`, how many the peer has too, as far as we /// know (its heads' history, and what went either way since, `sent_hashes`). A delta /// it offers from `from` brings those again: offered before it heard what we have diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index 6729c7d..6e216a9 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -577,6 +577,7 @@ async fn run(seed: u64, scenario: &'static Scenario) -> String { converged, ); trees(&mut out, &nodes, &sim.net).await; + sent_kept(&mut out, &nodes).await; if let Some(writer) = writer { slowest(&mut out, &nodes, &nodes[writer], &sim.net).await; } @@ -662,6 +663,29 @@ async fn trees(out: &mut String, nodes: &[AppState], net: &crate::transport::sim ); } +/// How many changes each session counts as sent to its peer (`SyncSession::sent_hashes_len`), +/// after the workload: the most, and on average. Kept until the peer's next message +/// says it has them; a session whose peer never sends one (along a tree, with one +/// writer) keeps all. +async fn sent_kept(out: &mut String, nodes: &[AppState]) { + let mut most = 0; + let mut sum = 0; + let mut sessions = 0; + for node in nodes { + for (_, peer_state) in node.peers_snapshot().await { + let kept = peer_state.lock().await.sync.sent_hashes_len(); + most = most.max(kept); + sum += kept; + sessions += 1; + } + } + let _ = writeln!( + out, + " changes counted as sent, per session: {most} at most, {:.1} on average", + sum as f64 / f64::from(sessions.max(1)), + ); +} + /// Whether the nodes' views of the writers' trees agree: each member's parent as the /// member chose it (`swarm::tree::own_parent`) against what that parent and the /// others plan (`swarm::tree::plan`: their children, the neighbours they count as |
