From 397a18c2c517b2c407e164736c0d40193cf0522c Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Mon, 18 Nov 2024 21:40:29 +0200 Subject: [PATCH] Print the number of mutate messages sent --- src/server.rs | 7 +++++-- src/server/replication_messages/mutate_message.rs | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server.rs b/src/server.rs index adba6d0f..8e053ecb 100644 --- a/src/server.rs +++ b/src/server.rs @@ -370,8 +370,7 @@ fn send_messages( if !mutate_message.is_empty() { let server_tick = write_tick_cached(&mut server_tick_range, serialized, server_tick)?; - trace!("sending mutate message(s) to {:?}", client.id()); - mutate_message.send( + let messages_count = mutate_message.send( server, client, client_buffers, @@ -380,6 +379,10 @@ fn send_messages( change_tick.this_run(), time.elapsed(), )?; + trace!( + "sending {messages_count} mutate message(s) to {:?}", + client.id() + ); } else { trace!("no mutations to send for {:?}", client.id()); } diff --git a/src/server/replication_messages/mutate_message.rs b/src/server/replication_messages/mutate_message.rs index 2905b586..20d21e1a 100644 --- a/src/server/replication_messages/mutate_message.rs +++ b/src/server/replication_messages/mutate_message.rs @@ -128,7 +128,7 @@ impl MutateMessage { server_tick: Range, tick: Tick, timestamp: Duration, - ) -> bincode::Result<()> { + ) -> bincode::Result { debug_assert_eq!(self.entities.len(), self.mutations.len()); const MAX_TICK_SIZE: usize = mem::size_of::() + 1; @@ -168,6 +168,7 @@ impl MutateMessage { .push((mutate_index, message_size, mutations_range.clone())); } + let messages_count = self.messages.len(); for (mutate_index, message_size, mutations_range) in self.messages.drain(..) { let mut message = Vec::with_capacity(message_size); @@ -187,7 +188,7 @@ impl MutateMessage { server.send(client.id(), ReplicationChannel::Mutations, message); } - Ok(()) + Ok(messages_count) } /// Clears all chunks.