Repository navigation
perf(command-bus): debounce per-send peer-registry disk load (-46% LAN RTT) - #1260
Merged
Merged
Conversation
…N RTT) Profiled the full LAN request/reply path with a new seam-timing util and a latency bench. The dominant cost was NOT the wire (serialize 24us + flush 20us + transport 47us) — it was `send_frame_to_room` calling `sync_account_peer_registry()` on EVERY send, which loads the peer registry from DISK and re-enrols every peer. That was ~95% of the send leg (~1ms/send). The verifier registry holds peer pubkeys for INBOUND verification and rarely changes between sends, so loading it per outbound message is wasted critical- path I/O. Debounce it: `sync_account_peer_registry_debounced` loads at most once/sec; a burst of sends pays the disk load once. add_peer still enrols in-memory immediately, and the route-refresh tick still calls the undebounced sync, so freshness is preserved. LAN round-trip: 2852us -> 1531us (-46%). Both command_bus_round_trip tests (LAN + relay) still pass. Adds (reusable, the shared-core lives in airc since continuum imports it): - airc-diagnostics::timing — opt-in seam accumulator (atomic-gated, near-zero when off), the SUMMED twin of probe!/time_probe!. Read by a bench to find "where did the ms go." - send-path seams (airc.sign/append_sent/exec_route, lan.serialize/flush_ack/ send_total, airc.req.*) — permanent opt-in observability of the send path. - lan_latency_bench (#[ignore]) — the harness that found this + measures the next lever. Remaining levers (measured, next): airc.sign 113us + airc.append_sent 107us per send (~690us/RTT is crypto + durability). append_sent's local durability write is backgroundable but delicate (dedup-ring/ordering) — a follow-up. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…t the frame) Captures the design for the next latency lever after the registry-debounce fix: per-frame Ed25519 (~113µs) is correct for the low-rate CONTROL plane (end-to-end authenticity across relays) but a throughput killer for the high-rate STREAM plane (WebRTC media, UDP). The fix is the standard DTLS-SRTP/QUIC/Noise pattern — sign the session/handle ONCE (Ed25519 → X25519/HKDF), then per-frame symmetric AEAD (ChaCha20-Poly1305), keyed off FrameKind/RouteClass. WebRTC media is already DTLS-SRTP; bind the DTLS fingerprint → peer identity at SDP-offer. Spec only; implementation is a coordinated transport change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…en timing off Adversarial review of #1260 (finding 1): the six manual `record()` seams called `std::time::Instant::now()` UNCONDITIONALLY, so a production send with timing disabled paid ~6 clock_gettime calls (~120ns) on the very path this PR speeds up — self-contradictory with the perf doctrine. Add `timing::start() -> ScopedTimer`: captures the Instant ONLY when recording is enabled (one relaxed atomic load otherwise, no clock read), records on `.stop()`. Convert all six await-span seams (airc.req.subscribe/send_frame, airc.append_sent/ exec_route, lan.flush_ack/send_total) to it. Disabled hot path is now truly zero-cost; bench still prints the full breakdown; RTT unchanged (~1505µs). Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
What
Profiled the full LAN request/reply path (new seam-timing util + a latency bench). The dominant cost was not the wire — it was
send_frame_to_roomcallingsync_account_peer_registry()on every send, which loads the peer registry from disk and re-enrols every peer. That was ~95% of the send leg (~1ms/send).The verifier registry holds peer pubkeys for inbound verification and rarely changes between sends, so loading it per outbound message is wasted critical-path I/O. Debounced to load at most once/sec.
Result (LAN loopback, sequential RTT)
Both
command_bus_round_triptests (LAN + relay) still pass.add_peerenrols in-memory immediately and the route-refresh tick still calls the undebounced sync, so freshness is preserved.Also adds (reusable diagnostics — shared core lives in airc since continuum imports it)
airc-diagnostics::timing— opt-in seam accumulator (atomic-gated, near-zero when off), the summed twin ofprobe!/time_probe!.airc.sign/append_sent/exec_route,lan.*,airc.req.*).lan_latency_bench(#[ignore]) — the harness that found this + measures the next lever.Next levers (measured)
airc.sign113µs +airc.append_sent107µs per send (~690µs/RTT is crypto + durability).append_sent's local durability write is backgroundable but delicate (dedup-ring/ordering) — a follow-up.🤖 Generated with Claude Code