perf(facade): batch V2 control-path replies in ProcessControlMessages#7479
Conversation
When ProcessControlMessages wakes with multiple messages queued, each std::visit call triggers FinishScope() -> Flush(), producing one sendmsg syscall per message (PubSub, Monitor, Invalidation). Enable batch mode when dispatch_q_ holds more than one message, so all replies in the drain pass accumulate in the send buffer and flush together at the main loop's idle-await point. Single-message wakeups are unaffected: SetBatchMode(false) leaves FinishScope() flushing immediately, preserving p=1 latency. Cross-machine benchmark (10 subscribers, 4 threads): PIPELINE RPS Δ SYSCALLS Δ 1 +3% -24% 10 +12% -68% 100 -1.4% -69% 500 -2% -70% RPS is publisher-bound at p>=100; the syscall reduction is the real gain — freeing kernel and NIC resources under fan-out load. Signed-off-by: Gil Levkovich <69595609+glevkovich@users.noreply.github.com>
Review Summary by QodoBatch V2 control-path replies in ProcessControlMessages
WalkthroughsDescription• Batch control-path replies when multiple messages queued • Reduces syscalls per message via deferred flush • Preserves single-message latency with conditional batching • Improves throughput under fan-out load (12% RPS, -68% syscalls at p=10) |
Code Review by Qodo
1. Wrong batching heuristic
|
🤖 Augment PR SummarySummary: Batches RESP V2 control-path replies in 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
This PR reduces per-message network flushes in the IoLoopV2 control path by batching replies produced while draining dispatch_q_ in Connection::ProcessControlMessages, aiming to cut sendmsg syscall volume under PubSub/Monitor/Invalidation fan-out.
Changes:
- Enable
SinkReplyBuilderbatch mode whendispatch_q_contains more than one queued control message. - Add an
absl::Cleanupguard to reliably restore non-batched mode on all exit paths fromProcessControlMessages.
When ProcessControlMessages wakes with multiple messages queued, each std::visit call triggers FinishScope() -> Flush(), producing one sendmsg syscall per message (PubSub, Monitor, Invalidation).
Enable batch mode when dispatch_q_ holds more than one message, so all replies in the drain pass accumulate in the send buffer and flush together at the main loop's idle-await point.
Single-message wakeups are unaffected: SetBatchMode(false) leaves FinishScope() flushing immediately, preserving p=1 latency.
Cross-machine benchmark (10 subscribers, 4 threads):
The syscall reduction is the real gain here.