summaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-26 19:45:21 +0100
committertv <tv@krebsco.de>2026-10-26 19:45:21 +0100
commit8edc7242b0b72853bccb3f1c1c841e81ebb3c6b3 (patch)
treed6067794054af9d4562634eb5055cb114c774d2d /src/swarm/sync.rs
parent4bbadf6fdc4733b4c3c5eeb575508b2f9334ebdb (diff)
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.
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs4
1 files changed, 3 insertions, 1 deletions
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<Option<(bool, bool)>> {
+ // 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