From 9aad4bee0fbcac76e96b3ff4e6c57a28b162b861 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Nov 2026 20:07:47 +0100 Subject: chunk fetch counters --- src/swarm/blob.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/swarm/blob.rs') diff --git a/src/swarm/blob.rs b/src/swarm/blob.rs index 82586b8..f3494af 100644 --- a/src/swarm/blob.rs +++ b/src/swarm/blob.rs @@ -642,6 +642,7 @@ pub(crate) async fn fetch( doubled.insert(*index); sources[at].in_flight.insert(*index, now); } + state.stats.chunks_doubled(batch.len()); request(state, &sources[at].peer, id, batch, delta).await; } } @@ -665,7 +666,11 @@ pub(crate) async fn fetch( let at = sources.iter().position(|source| source.peer == from); let sent_at = at.and_then(|at| sources[at].in_flight.remove(&index)); let slot = index as usize; - if slot >= total || chunks[slot].is_some() { + if slot >= total { + continue; + } + if chunks[slot].is_some() { + state.stats.chunk_twice(); continue; } let expected = expected_len(&manifest, slot); @@ -687,6 +692,9 @@ pub(crate) async fn fetch( // A peer that delivers may have one more in flight. source.window = (source.window + 1).min(MAX_WINDOW); } + if at.is_none() { + state.stats.chunk_from_dropped(); + } chunks[slot] = Some(data); done += 1; last_progress = Instant::now(); @@ -724,6 +732,9 @@ pub(crate) async fn fetch( .in_flight .retain(|_, sent| now.saturating_duration_since(*sent) < timeout); if source.in_flight.len() < before { + state + .stats + .chunks_timed_out(before - source.in_flight.len()); source.window = 1; debug!(peer = %source.peer, blob = %id, "Blob chunks timed out; asking others"); } -- cgit v1.3.1