diff options
| author | tv <tv@krebsco.de> | 2026-11-05 04:11:34 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-05 04:11:34 +0100 |
| commit | fd268e2a7c8ff7e7707ae79b4f4916a50f222188 (patch) | |
| tree | 8a08177c77bfa64e177749e7b758b895443631bc /src/swarm/stats.rs | |
| parent | f0ef5c33998964d21c5cf5c582cd194327429003 (diff) | |
measure deflated chunks
Diffstat (limited to 'src/swarm/stats.rs')
| -rw-r--r-- | src/swarm/stats.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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(); |
