From 5854fe5a3a7c7e8f681264d3a4b27597a8c61de0 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 20:48:45 +0100 Subject: add sync and relay stats --- src/swarm/stats.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/swarm/stats.rs') diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs index f9a5b7b..8172233 100644 --- a/src/swarm/stats.rs +++ b/src/swarm/stats.rs @@ -29,6 +29,8 @@ struct Inner { catch_up_sources: u32, max_heads: usize, stale_hello_replies: u64, + relay: Relay, + blob_requests_dropped: u64, saved_size: Option, measuring: bool, /// The document version (`AppState::change_tx`) and epoch the saved size is of. @@ -90,6 +92,17 @@ pub(crate) struct SavedSize { pub(crate) took: Duration, } +/// Passing changes on (`swarm::relay`), since start. +#[derive(Debug, Clone, Copy, Default)] +pub(crate) struct Relay { + /// Announcement rounds (each a PING to the neighbours). + pub(crate) announce_rounds: u64, + /// Pulls started. + pub(crate) pulls: u64, + /// Announcements of heads we lacked that had to wait for the pull in progress. + pub(crate) pulls_queued: u64, +} + /// When the initial sync finished, and what it took. #[derive(Debug, Clone, Copy)] pub(crate) struct CaughtUp { @@ -107,6 +120,8 @@ pub(crate) struct Snapshot { pub(crate) catch_up_sources: u32, pub(crate) max_heads: usize, pub(crate) stale_hello_replies: u64, + pub(crate) relay: Relay, + pub(crate) blob_requests_dropped: u64, pub(crate) propagation: Propagation, } @@ -154,6 +169,23 @@ impl NodeStats { self.lock().stale_hello_replies += 1; } + pub(crate) fn announce_round(&self) { + self.lock().relay.announce_rounds += 1; + } + + pub(crate) fn pull_started(&self) { + self.lock().relay.pulls += 1; + } + + pub(crate) fn pull_queued(&self) { + self.lock().relay.pulls_queued += 1; + } + + /// A blob request went unanswered: too many were being answered. + pub(crate) fn blob_request_dropped(&self) { + self.lock().blob_requests_dropped += 1; + } + /// The last measurement of the saved size, if any. pub(crate) fn saved_size(&self) -> Option { self.lock().saved_size @@ -203,6 +235,8 @@ impl NodeStats { catch_up_sources: inner.catch_up_sources, max_heads: inner.max_heads, stale_hello_replies: inner.stale_hello_replies, + relay: inner.relay, + blob_requests_dropped: inner.blob_requests_dropped, propagation: inner.propagation, } } -- cgit v1.3.1