-
-
Notifications
You must be signed in to change notification settings - Fork 123
perf(signal): coalesce receive flushes and persist outbound state pre-wire #1022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
62ff07f
f2d0212
430b221
1693785
a75cfc4
4e1a851
47b33d5
b46e161
4e3e736
7be4107
4d1b8fa
6549dcd
fea31e0
9cf00c5
10a06db
14b9cac
8a38d46
4b6522c
935c83c
ef1cf76
63fe36b
1b476b7
43561b8
d6b2997
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,14 @@ impl Client { | |
| pair_code_state: Arc::new(Mutex::new(wacore::pair_code::PairCodeState::default())), | ||
| passkey_state: Arc::new(Mutex::new(crate::passkey::flow::PasskeyFlowState::default())), | ||
| passkey_opening: AtomicBool::new(false), | ||
| signal_flush_state: AtomicU64::new(0), | ||
| signal_flush_lifecycle: async_lock::Mutex::new(()), | ||
| #[cfg(test)] | ||
| signal_flush_test_failures: AtomicU32::new(0), | ||
| #[cfg(test)] | ||
| signal_flush_test_block: AtomicBool::new(false), | ||
| #[cfg(test)] | ||
| signal_flush_test_in_attempt: AtomicU32::new(0), | ||
| custom_enc_handlers: std::sync::OnceLock::new(), | ||
| inbound_durability_hook: std::sync::OnceLock::new(), | ||
| retry_admission: std::sync::OnceLock::new(), | ||
|
|
@@ -764,6 +772,9 @@ impl Client { | |
| // permit-held cache settle below, so no rowless ratchet advances can | ||
| // dirty the cache behind teardown's back. | ||
| self.connection_generation.fetch_add(1, Ordering::SeqCst); | ||
| // The coalesced-flush scheduler needs no explicit reset: its state is | ||
| // generation-scoped, so the bump above already hands ownership to the | ||
| // next connection's first request and retires any stale worker. | ||
| // Note: node_waiters are intentionally NOT cleared here — they are | ||
| // cross-connection (callers may register a waiter before an action that | ||
| // completes on a subsequent connection, e.g. after 515 reconnect). | ||
|
|
@@ -830,6 +841,13 @@ impl Client { | |
| // the durable hook commit is what matters. Reached on every teardown | ||
| // path, including the run loop's unexpected read-loop exit, which | ||
| // never goes through disconnect(). | ||
| // | ||
| // Hold the coalesced-flush barrier across the whole settle: a stale flush | ||
| // worker that already passed its generation check must not interleave a | ||
| // backend write between our commit and the next connection's drain, or it | ||
| // could persist that drain's rowless advances. The worker re-checks the | ||
| // generation (bumped above) once it gets the gate, so it stands down. | ||
| let flush_gate = self.signal_flush_lifecycle.lock().await; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Disconnect/reconnect can hang indefinitely when a pre-existing coalesced worker is stalled acquiring the processing permit or writing storage. Include lifecycle-gate acquisition in the teardown deadline (or otherwise cancel/bound the worker) so the existing bounded-settle guarantee still covers this wait. Prompt for AI agents |
||
| if let Some(client) = self.self_weak.get().and_then(|w| w.upgrade()) { | ||
| client | ||
| .teardown_inbound_commits_bounded(std::time::Duration::from_secs(5)) | ||
|
|
@@ -864,6 +882,8 @@ impl Client { | |
| ); | ||
| self.signal_cache.clear().await; | ||
| } | ||
| // Cache is settled and any dropped entries cleared; a worker may run again. | ||
| drop(flush_gate); | ||
| self.offline_batch.reset(); | ||
| self.offline_sync_metrics | ||
| .active | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.