aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-04 20:50:40 +0100
committertv <tv@krebsco.de>2026-11-04 20:50:40 +0100
commited89f782561eebe281a63e90f6bbdcbb025c2f81 (patch)
tree63046f33f9952688fbf392b703b44ebc1c31e193 /src/swarm
parentdfd394f5ac2b12d43c4c556497938790ca56310f (diff)
benchmark where twice comes from
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/stats.rs13
-rw-r--r--src/swarm/sync.rs2
2 files changed, 11 insertions, 4 deletions
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs
index da7544f..34542ff 100644
--- a/src/swarm/stats.rs
+++ b/src/swarm/stats.rs
@@ -115,9 +115,13 @@ pub(crate) struct Relay {
pub(crate) delivered: u64,
pub(crate) delivered_bytes: u64,
/// Sync messages received that carried changes, all of which we had already, and
- /// their payload's bytes: changes that came twice.
+ /// their payload's bytes: changes that came twice. Of those, how many came along a
+ /// writer's tree (`SyncEnvelope::writer`), and how many were taken as delivered by
+ /// their sender (`SyncEnvelope::delivered`).
pub(crate) nothing_new: u64,
pub(crate) nothing_new_bytes: u64,
+ pub(crate) nothing_new_along_trees: u64,
+ pub(crate) nothing_new_delivered: u64,
}
/// When the initial sync finished, and what it took.
@@ -219,11 +223,14 @@ impl NodeStats {
inner.relay.delivered_bytes += bytes as u64;
}
- /// A sync message of `bytes` payload carried changes, all of which we had already.
- pub(crate) fn nothing_new(&self, bytes: usize) {
+ /// A sync message of `bytes` payload carried changes, all of which we had already;
+ /// it came `along_tree`, or was `delivered`.
+ pub(crate) fn nothing_new(&self, bytes: usize, along_tree: bool, delivered: bool) {
let mut inner = self.lock();
inner.relay.nothing_new += 1;
inner.relay.nothing_new_bytes += bytes as u64;
+ inner.relay.nothing_new_along_trees += u64::from(along_tree);
+ inner.relay.nothing_new_delivered += u64::from(delivered);
}
/// A sync message of `bytes` arrived.
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 3737f85..ab45b37 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -441,7 +441,7 @@ pub(crate) async fn handle_sync(
stats.heads_seen(heads_after.len());
let changed = heads_after != heads_before;
if carried && !changed {
- stats.nothing_new(payload_len);
+ stats.nothing_new(payload_len, writer.is_some(), delivered);
}
// Whose they are, to pass them on along their writers' trees, however they
// came (along a tree, with an answer, pulled).