fix(dkg): relax started atomic ordering from SeqCst to Relaxed#550
Open
varex83 wants to merge 1 commit into
Open
fix(dkg): relax started atomic ordering from SeqCst to Relaxed#550varex83 wants to merge 1 commit into
started atomic ordering from SeqCst to Relaxed#550varex83 wants to merge 1 commit into
Conversation
The `started` flag in the DKG sync server is a standalone signal that publishes no data of its own: server state lives behind an `RwLock` and wake-ups are delivered via `Notify`. There is only one atomic involved, so the global total order imposed by `SeqCst` is unnecessary; `Relaxed` is sufficient and avoids the extra fences (notably on AArch64). Also document why `Relaxed` is already correct for the QBFT runner's `decided` flag, whose visibility is guaranteed by the spawn_blocking join rather than the atomic ordering.
started atomic ordering from SeqCst to Relaxedstarted atomic ordering from SeqCst to Relaxed
iamquang95
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audited all production atomic-ordering usage in the workspace. The vast majority of sites already use the optimal ordering; this PR addresses the single inefficiency found.
crates/dkg/src/sync/server.rs— thestartedAtomicBoolusedSeqCstfor its store/load (3 sites). The flag is a standalone signal: it publishes no data of its own (server state lives behind theRwLock, wake-ups come fromNotify), and it is the only atomic in play. A global total order (SeqCst) is therefore unnecessary — it just adds fences (dmb ish+ldar/stlron AArch64;xchg/mfencevs. plainmovon x86). Downgraded toRelaxed, which is sufficient for the register-then-checkNotifyidiom (correctness comes from registeringnotified()before the load, not from the atomic's ordering).Also added an explanatory comment on the QBFT runner's
decidedflag documenting why its existingRelaxedload is already correct (visibility is guaranteed by thespawn_blockingjoin, not the atomic ordering).Audit result (production sites)
consensus/instance.rsRelaxedMutex)consensus/qbft/p2p.rs,parsigex/behaviour.rsRelaxedconsensus/qbft/runner.rsdecidedRelaxeddkg/sync/server.rsstartedSeqCst→RelaxedNo correctness bugs were found — no
Relaxedsite was dangerously under-strengthened.Testing
cargo build -p pluto-dkg -p pluto-consensuscargo clippy -p pluto-dkg -p pluto-consensus --all-targets --all-features -- -D warnings