chore: fixed collab ack

This commit is contained in:
Bartosz Sypytkowski 2024-10-23 10:52:37 +02:00
parent 0032b7e08e
commit 5d0d8cf4d1
2 changed files with 11 additions and 6 deletions

View File

@ -200,7 +200,7 @@ impl CollabGroup {
sv.merge(update.state_vector); sv.merge(update.state_vector);
drop(sv); drop(sv);
let seq_num = state.seq_no.fetch_add(1, Ordering::SeqCst); let seq_num = state.seq_no.fetch_add(1, Ordering::SeqCst) + 1;
tracing::trace!( tracing::trace!(
"broadcasting collab update from {} ({} bytes) - seq_num: {}", "broadcasting collab update from {} ({} bytes) - seq_num: {}",
update.sender, update.sender,
@ -493,7 +493,7 @@ impl CollabGroup {
message_origin, message_origin,
state.object_id.to_string(), state.object_id.to_string(),
msg_id, msg_id,
state.seq_no.fetch_add(1, Ordering::SeqCst), state.seq_no.load(Ordering::SeqCst),
)); ));
} }
@ -547,7 +547,7 @@ impl CollabGroup {
message_origin.clone(), message_origin.clone(),
state.object_id.to_string(), state.object_id.to_string(),
msg_id, msg_id,
state.seq_no.fetch_add(1, Ordering::SeqCst), state.seq_no.load(Ordering::SeqCst),
) )
.with_payload(payload.unwrap_or_default()), .with_payload(payload.unwrap_or_default()),
); );
@ -571,7 +571,7 @@ impl CollabGroup {
message_origin.clone(), message_origin.clone(),
state.object_id.to_string(), state.object_id.to_string(),
msg_id, msg_id,
state.seq_no.fetch_add(1, Ordering::SeqCst), state.seq_no.load(Ordering::SeqCst),
) )
.with_code(code) .with_code(code)
.with_payload(payload), .with_payload(payload),

View File

@ -1,4 +1,4 @@
use std::time::Duration; use std::time::{Duration, Instant};
use anyhow::Context; use anyhow::Context;
use collab::core::origin::CollabOrigin; use collab::core::origin::CollabOrigin;
@ -134,7 +134,12 @@ impl TestScenario {
} }
pub async fn execute(&self, collab: CollabRef) -> String { pub async fn execute(&self, collab: CollabRef) -> String {
for t in self.txns.iter() { let len = self.txns.len();
let start = Instant::now();
for (i, t) in self.txns.iter().take(50_000).enumerate() {
if i % 10_000 == 0 {
tracing::trace!("step #{}/{} - {:?}", i + 1, len, start.elapsed());
}
let mut lock = collab.write().await; let mut lock = collab.write().await;
let collab = lock.borrow_mut(); let collab = lock.borrow_mut();
let mut txn = collab.context.transact_mut(); let mut txn = collab.context.transact_mut();