From be0d9b01b500645fd5b8578409e88271a8090d60 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Nov 2026 16:11:56 +0100 Subject: no bloom bytes --- src/document/sync.rs | 23 +++++++++-------------- src/simtest/bench.rs | 9 +-------- src/swarm/stats.rs | 20 ++++++++------------ src/swarm/sync.rs | 6 +++--- 4 files changed, 21 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/document/sync.rs b/src/document/sync.rs index 1fc5589..bfa0fef 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -97,16 +97,9 @@ impl Received { &self.0.heads } - /// The bytes of the changes it carries, and of its bloom filters (`have`). - pub(crate) fn sizes(&self) -> (usize, usize) { - let changes = self.0.changes.iter().map(<[u8]>::len).sum(); - let blooms = self - .0 - .have - .iter() - .map(|have| have.bloom.to_bytes().len()) - .sum(); - (changes, blooms) + /// The bytes of the changes it carries. + pub(crate) fn change_bytes(&self) -> usize { + self.0.changes.iter().map(<[u8]>::len).sum() } } @@ -1423,7 +1416,7 @@ mod tests { } assert_eq!(theirs.get_heads(), ours.get_heads()); if let Some(answer) = b.generate(&theirs, now, bytes) { - let (carried, _) = decode(&answer).unwrap().sizes(); + let carried = decode(&answer).unwrap().change_bytes(); assert_eq!(carried, 0, "a's own changes went back to it"); } } @@ -1493,7 +1486,7 @@ mod tests { a.known_to_peer(&ours.get_heads(), Instant::now()); let message = a.generate(&ours, now, bytes).expect("our heads moved"); a.send_succeeded(a.id()); - let (carried, _) = decode(&message).unwrap().sizes(); + let carried = decode(&message).unwrap().change_bytes(); assert_eq!(carried, 0, "not sent: the peer gets it from elsewhere"); // It didn't: it asks, and gets it. @@ -1631,13 +1624,15 @@ mod tests { b.came_from_peer(&theirs, &before); let level = b.answered_as_delivered(&theirs, &theirs.get_heads()); let answer = b.generate(&theirs, now, bytes).map(|m| decode(&m).unwrap()); - let answered = answer.as_ref().map(|m| (m.heads().to_vec(), m.sizes().0)); + let answered = answer + .as_ref() + .map(|m| (m.heads().to_vec(), m.change_bytes())); if let Some(answer) = answer { a.receive(&mut ours, answer).unwrap(); } let next = a .generate(&ours, now, bytes) - .map(|m| decode(&m).unwrap().sizes().0); + .map(|m| decode(&m).unwrap().change_bytes()); (theirs.get_heads(), level, answered, ours.get_heads(), next) }; assert_eq!(outcome(true), outcome(false), "concurrent: {concurrent}"); diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index dd7d892..6cc1fad 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -343,12 +343,10 @@ impl Totals { relay.nothing_new_delivered += stats.relay.nothing_new_delivered; relay.carrying += stats.relay.carrying; relay.carrying_change_bytes += stats.relay.carrying_change_bytes; - relay.carrying_bloom_bytes += stats.relay.carrying_bloom_bytes; relay.new_changes += stats.relay.new_changes; relay.asked_known_lately += stats.relay.asked_known_lately; relay.asked_known_later += stats.relay.asked_known_later; relay.nothing_new_change_bytes += stats.relay.nothing_new_change_bytes; - relay.nothing_new_bloom_bytes += stats.relay.nothing_new_bloom_bytes; relay.waiting += stats.relay.waiting; relay.off_tree += stats.relay.off_tree; relay.off_tree_ms += stats.relay.off_tree_ms; @@ -737,21 +735,16 @@ fn report( let twice = r1.nothing_new - r0.nothing_new; let _ = writeln!( out, - " received with changes: {:.1} per write, each {:.0} bytes of changes and {:.0} of bloom filters; of those with nothing new, {:.0} and {:.0}", + " received with changes: {:.1} per write, each {:.0} bytes of changes; of those with nothing new, {:.0}", carrying as f64 / writes, each( r1.carrying_change_bytes - r0.carrying_change_bytes, carrying ), - each(r1.carrying_bloom_bytes - r0.carrying_bloom_bytes, carrying), each( r1.nothing_new_change_bytes - r0.nothing_new_change_bytes, twice ), - each( - r1.nothing_new_bloom_bytes - r0.nothing_new_bloom_bytes, - twice - ), ); // Bytes of changes per new change in the messages that brought some: several // changes per message, or larger changes. diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs index 8ab27e8..02ccad5 100644 --- a/src/swarm/stats.rs +++ b/src/swarm/stats.rs @@ -149,13 +149,11 @@ 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. + /// Sync messages received that carried changes, and the bytes of those changes; 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, /// Sync messages received that carried changes, none of them applied yet: they wait /// for predecessors that didn't come (Automerge holds them back). Not counted with /// `nothing_new`, which they aren't. @@ -298,21 +296,20 @@ impl NodeStats { } /// A sync message of `bytes` payload carried changes, all of which we had already; - /// it came `along_tree`, or was `delivered`; `sizes`: of its changes and blooms. + /// it came `along_tree`, or was `delivered`; `change_bytes`: of its changes. pub(crate) fn nothing_new( &self, bytes: usize, along_tree: bool, delivered: bool, - sizes: (usize, usize), + change_bytes: 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; + inner.relay.nothing_new_change_bytes += change_bytes as u64; } /// A sync message carried changes that wait for predecessors (`Relay::waiting`). @@ -328,12 +325,11 @@ impl NodeStats { inner.relay.off_tree_ms += delays_ms.iter().map(|ms| ms.max(&0)).sum::() as u64; } - /// A sync message carrying changes arrived; `sizes`: of its changes and blooms. - pub(crate) fn carrying(&self, sizes: (usize, usize)) { + /// A sync message carrying `change_bytes` of changes arrived. + pub(crate) fn carrying(&self, change_bytes: 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; + inner.relay.carrying_change_bytes += change_bytes as u64; } /// A peer asked for changes we had counted as its (`SyncSession::resend_if_needed`). diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 5ee36a2..a6467a7 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -561,9 +561,9 @@ pub(crate) async fn handle_sync( return Ok(None); } let carried = message.carries_changes(); - let sizes = if carried { message.sizes() } else { (0, 0) }; + let change_bytes = if carried { message.change_bytes() } else { 0 }; if carried { - stats.carrying(sizes); + stats.carrying(change_bytes); } let mut peer_state = peer_state_mutex.blocking_lock(); @@ -621,7 +621,7 @@ pub(crate) async fn handle_sync( if !crate::document::changes::holds_all(&replica.doc, &said) { stats.waiting(); } else { - stats.nothing_new(payload_len, writer.is_some(), delivered, sizes); + stats.nothing_new(payload_len, writer.is_some(), delivered, change_bytes); } } // Whose they are, to pass them on along their writers' trees, however they -- cgit v1.3.1