Skip to content

Commit

Permalink
Print the number of mutate messages sent
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Nov 18, 2024
1 parent 9f204f8 commit 397a18c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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());
}
Expand Down
5 changes: 3 additions & 2 deletions src/server/replication_messages/mutate_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl MutateMessage {
server_tick: Range<usize>,
tick: Tick,
timestamp: Duration,
) -> bincode::Result<()> {
) -> bincode::Result<usize> {
debug_assert_eq!(self.entities.len(), self.mutations.len());

const MAX_TICK_SIZE: usize = mem::size_of::<RepliconTick>() + 1;
Expand Down Expand Up @@ -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);

Expand All @@ -187,7 +188,7 @@ impl MutateMessage {
server.send(client.id(), ReplicationChannel::Mutations, message);
}

Ok(())
Ok(messages_count)
}

/// Clears all chunks.
Expand Down

0 comments on commit 397a18c

Please sign in to comment.