From 8edc7242b0b72853bccb3f1c1c841e81ebb3c6b3 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 19:45:21 +0100 Subject: decode sync messages lazily Sync messages are now being decoded only where they are applied: after membership has been checked, in the sync lane's blocking task. Debug now shows only the size instead of the whole message. --- src/swarm/sync.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/swarm/sync.rs') diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 0fbff05..ca54fae 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -159,7 +159,7 @@ async fn deliver_sync_to_peer(state: &AppState, peer: &str) -> Result<()> { swarm_id, epoch, epoch_seq, - message, + message: transport::SyncPayload::encode(message), ready, }; let encoded = transport @@ -336,6 +336,8 @@ pub(crate) async fn handle_sync( // Some((caught_up, heads changed)) when applied, None when the message belongs // to another epoch. tokio::task::spawn_blocking(move || -> Result> { + // Before the lock: decoding a large message takes a while. + let message = message.decode()?; let mut replica = doc.blocking_write(); // Authoritative check, under the same lock as the apply: the document may -- cgit v1.3.1