aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-03 06:11:06 +0100
committertv <tv@krebsco.de>2026-11-03 06:11:06 +0100
commitb16977b18fdd1e5193f5c015eadcb61a63f4fae1 (patch)
tree197a9fb7c0c0f5d5b799ecc3f3363c628a4f5e12 /src/swarm
parent698ab19bb74e1dbbc7c52fef96caede4d92caf55 (diff)
announcement round counters
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/relay.rs14
-rw-r--r--src/swarm/stats.rs17
2 files changed, 23 insertions, 8 deletions
diff --git a/src/swarm/relay.rs b/src/swarm/relay.rs
index 29da2eb..a8560a5 100644
--- a/src/swarm/relay.rs
+++ b/src/swarm/relay.rs
@@ -104,7 +104,7 @@ pub(crate) async fn announce(state: &AppState, from: &str, writer: Option<u64>)
schedule
};
if schedule {
- round(state, &state.announce_pending, ANNOUNCE_DELAY);
+ round(state, &state.announce_pending, ANNOUNCE_DELAY, false);
}
if !tree {
return;
@@ -121,15 +121,17 @@ pub(crate) async fn announce(state: &AppState, from: &str, writer: Option<u64>)
schedule
};
if schedule {
- round(state, &state.announce_slow, SLOW_ANNOUNCE_DELAY);
+ round(state, &state.announce_slow, SLOW_ANNOUNCE_DELAY, true);
}
}
-/// An announcement round of what `pending` collects, `delay` (and a jitter) from now.
+/// An announcement round of what `pending` collects, `delay` (and a jitter) from now:
+/// the `slow` one, or the quick one.
fn round(
state: &AppState,
pending: &std::sync::Arc<std::sync::Mutex<Option<Pending>>>,
delay: Duration,
+ slow: bool,
) {
let state = state.clone();
let pending = std::sync::Arc::clone(pending);
@@ -140,14 +142,14 @@ fn round(
.max(1);
tokio::time::sleep(delay + Duration::from_millis(jitter)).await;
let pending = pending.lock_or_recover().take().unwrap_or_default();
- announce_now(&state, &pending).await;
+ announce_now(&state, &pending, slow).await;
});
}
/// One announcement round. The peer whose changes we announce has them already, so a
/// round with a single sender skips it; with several, each lacks the others' changes,
/// so every neighbour is told.
-async fn announce_now(state: &AppState, pending: &Pending) {
+async fn announce_now(state: &AppState, pending: &Pending, slow: bool) {
let mut neighbours = unreached(state, &pending.senders, &pending.sent).await;
if !pending.all {
neighbours.retain(|peer| pending.targets.contains(peer));
@@ -155,7 +157,7 @@ async fn announce_now(state: &AppState, pending: &Pending) {
if neighbours.is_empty() {
return;
}
- state.stats.announce_round();
+ state.stats.announce_round(pending.all, slow);
for peer in neighbours {
if let Err(error) = announce_heads(state, &peer, false).await {
debug!(peer = %peer, error = %format!("{error:#}"), "Announcing our heads failed");
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs
index 8a00629..9d32baa 100644
--- a/src/swarm/stats.rs
+++ b/src/swarm/stats.rs
@@ -98,6 +98,11 @@ pub(crate) struct SavedSize {
pub(crate) struct Relay {
/// Announcement rounds (each a STATUS to the neighbours).
pub(crate) announce_rounds: u64,
+ /// Of those, quick rounds to all neighbours, as some change came with no writer's
+ /// tree to go along (pulled, a delta, from a node with no part in it), and slow rounds
+ /// after changes that did (`swarm::relay`).
+ pub(crate) treeless_rounds: u64,
+ pub(crate) slow_rounds: u64,
/// Pulls started.
pub(crate) pulls: u64,
/// Announcements of heads we lacked that had to wait for the pull in progress.
@@ -175,8 +180,16 @@ impl NodeStats {
self.lock().stale_hello_replies += 1;
}
- pub(crate) fn announce_round(&self) {
- self.lock().relay.announce_rounds += 1;
+ /// An announcement round: `treeless` (quick, to all), `slow`, or else quick to
+ /// those writers' trees leave out.
+ pub(crate) fn announce_round(&self, treeless: bool, slow: bool) {
+ let mut inner = self.lock();
+ inner.relay.announce_rounds += 1;
+ if slow {
+ inner.relay.slow_rounds += 1;
+ } else if treeless {
+ inner.relay.treeless_rounds += 1;
+ }
}
pub(crate) fn pull_started(&self) {