From fd268e2a7c8ff7e7707ae79b4f4916a50f222188 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Nov 2026 04:11:34 +0100 Subject: measure deflated chunks --- src/swarm/stats.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/swarm/stats.rs') diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs index 6332901..31b6a3b 100644 --- a/src/swarm/stats.rs +++ b/src/swarm/stats.rs @@ -137,6 +137,11 @@ pub(crate) struct Relay { pub(crate) deflated: u64, pub(crate) deflated_from: u64, pub(crate) deflated_to: u64, + /// Blob chunks served, those of them deflated, and their bytes before and as sent. + pub(crate) chunks_served: u64, + pub(crate) chunks_deflated: u64, + pub(crate) chunk_bytes: u64, + pub(crate) chunk_bytes_sent: u64, /// Sync messages received that carried changes, all of which we had already, and /// 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 @@ -258,6 +263,15 @@ impl NodeStats { self.lock().relay.tree_forwards += 1; } + /// A blob chunk of `bytes` was served as `sent` bytes (fewer if deflated). + pub(crate) fn chunk_served(&self, bytes: usize, sent: usize) { + let mut inner = self.lock(); + inner.relay.chunks_served += 1; + inner.relay.chunks_deflated += u64::from(sent < bytes); + inner.relay.chunk_bytes += bytes as u64; + inner.relay.chunk_bytes_sent += sent as u64; + } + /// A sync message of `from` bytes went out deflated to `to`. pub(crate) fn deflated(&self, from: usize, to: usize) { let mut inner = self.lock(); -- cgit v1.3.1