diff options
| author | tv <tv@krebsco.de> | 2026-11-04 21:07:42 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-04 21:07:42 +0100 |
| commit | a8762b78d327e97c3c818842e5a948ba118fefd8 (patch) | |
| tree | 60308cecf72a0fa247f807746588a23f136f89ab /src/swarm | |
| parent | 9f4820d5d121025e908da9ca98783f2827044768 (diff) | |
benchmark what sync bytes are
Diffstat (limited to 'src/swarm')
| -rw-r--r-- | src/swarm/stats.rs | 27 | ||||
| -rw-r--r-- | src/swarm/sync.rs | 6 |
2 files changed, 30 insertions, 3 deletions
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs index 34542ff..905e668 100644 --- a/src/swarm/stats.rs +++ b/src/swarm/stats.rs @@ -122,6 +122,13 @@ pub(crate) struct Relay { pub(crate) nothing_new_bytes: u64, pub(crate) nothing_new_along_trees: u64, pub(crate) nothing_new_delivered: u64, + /// Sync messages received that carried changes, the bytes of those changes, and of + /// their bloom filters; and the same of those with nothing new. + pub(crate) carrying: u64, + pub(crate) carrying_change_bytes: u64, + pub(crate) carrying_bloom_bytes: u64, + pub(crate) nothing_new_change_bytes: u64, + pub(crate) nothing_new_bloom_bytes: u64, } /// When the initial sync finished, and what it took. @@ -224,13 +231,29 @@ impl NodeStats { } /// A sync message of `bytes` payload carried changes, all of which we had already; - /// it came `along_tree`, or was `delivered`. - pub(crate) fn nothing_new(&self, bytes: usize, along_tree: bool, delivered: bool) { + /// it came `along_tree`, or was `delivered`; `sizes`: of its changes and blooms. + pub(crate) fn nothing_new( + &self, + bytes: usize, + along_tree: bool, + delivered: bool, + sizes: (usize, usize), + ) { let mut inner = self.lock(); inner.relay.nothing_new += 1; inner.relay.nothing_new_bytes += bytes as u64; inner.relay.nothing_new_along_trees += u64::from(along_tree); inner.relay.nothing_new_delivered += u64::from(delivered); + inner.relay.nothing_new_change_bytes += sizes.0 as u64; + inner.relay.nothing_new_bloom_bytes += sizes.1 as u64; + } + + /// A sync message carrying changes arrived; `sizes`: of its changes and blooms. + pub(crate) fn carrying(&self, sizes: (usize, usize)) { + let mut inner = self.lock(); + inner.relay.carrying += 1; + inner.relay.carrying_change_bytes += sizes.0 as u64; + inner.relay.carrying_bloom_bytes += sizes.1 as u64; } /// A sync message of `bytes` arrived. diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 07c990c..04d06de 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -406,6 +406,10 @@ pub(crate) async fn handle_sync( let payload_len = message.0.len(); let message = crate::document::sync::decode(&message)?; let carried = message.carries_changes(); + let sizes = if carried { message.sizes() } else { (0, 0) }; + if carried { + stats.carrying(sizes); + } let mut replica = doc.blocking_write(); // Authoritative check, under the same lock as the apply: the document may @@ -447,7 +451,7 @@ pub(crate) async fn handle_sync( peer_state.sync.came_from_peer(&replica.doc, &heads_before); } if carried && !changed { - stats.nothing_new(payload_len, writer.is_some(), delivered); + stats.nothing_new(payload_len, writer.is_some(), delivered, sizes); } // Whose they are, to pass them on along their writers' trees, however they // came (along a tree, with an answer, pulled). |
