aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-03 03:26:15 +0100
committertv <tv@krebsco.de>2026-11-03 03:26:15 +0100
commit5b3d9cbd1bba986b06978bef0100d349b33e74c7 (patch)
treebb441a8636a3a01da6319b9f6c64e0695d0729b1 /src/swarm
parent2b4359f23d20b14bae1896512f678d02b7f3c34c (diff)
add eager link counters
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/relay.rs3
-rw-r--r--src/swarm/stats.rs18
2 files changed, 21 insertions, 0 deletions
diff --git a/src/swarm/relay.rs b/src/swarm/relay.rs
index fcca9c7..e11bd69 100644
--- a/src/swarm/relay.rs
+++ b/src/swarm/relay.rs
@@ -106,6 +106,7 @@ async fn forward_eagerly(state: &AppState, from: &str) {
continue;
}
if peer_state.lock().await.eager_to {
+ state.stats.eager_forward();
state.request_sync(&peer);
}
}
@@ -265,6 +266,7 @@ async fn graft(state: &AppState, peer: &str) {
if !set_eager_from(state, peer, true).await {
return;
}
+ state.stats.link_grafted();
debug!(peer = %peer, "Link eager: we want its changes as it applies them");
if let Err(error) = announce_heads(state, peer).await {
debug!(peer = %peer, error = %format!("{error:#}"), "Telling a neighbour the link is eager failed");
@@ -277,6 +279,7 @@ pub(crate) async fn prune(state: &AppState, peer: &str) {
if !set_eager_from(state, peer, false).await {
return;
}
+ state.stats.link_pruned();
debug!(peer = %peer, "Link lazy: its changes reach us first another way");
if let Err(error) = announce_heads(state, peer).await {
debug!(peer = %peer, error = %format!("{error:#}"), "Telling a neighbour the link is lazy failed");
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs
index 04f41b2..dd56bb0 100644
--- a/src/swarm/stats.rs
+++ b/src/swarm/stats.rs
@@ -102,6 +102,12 @@ pub(crate) struct Relay {
pub(crate) pulls: u64,
/// Announcements of heads we lacked that had to wait for the pull in progress.
pub(crate) pulls_queued: u64,
+ /// Links made eager (a pull brought changes over them) and lazy again (changes came
+ /// over them that another path brought first).
+ pub(crate) grafts: u64,
+ pub(crate) prunes: u64,
+ /// Changes forwarded over eager links: a sync message asked for per neighbour.
+ pub(crate) eager_forwards: u64,
}
/// When the initial sync finished, and what it took.
@@ -184,6 +190,18 @@ impl NodeStats {
self.lock().relay.pulls_queued += 1;
}
+ pub(crate) fn link_grafted(&self) {
+ self.lock().relay.grafts += 1;
+ }
+
+ pub(crate) fn link_pruned(&self) {
+ self.lock().relay.prunes += 1;
+ }
+
+ pub(crate) fn eager_forward(&self) {
+ self.lock().relay.eager_forwards += 1;
+ }
+
/// A sync message of `bytes` arrived.
pub(crate) fn sync_received(&self, bytes: usize) {
let mut inner = self.lock();