Repository navigation
Conversation
spscQueue placed tail_local and head_cache on the same cache line as tail. The consumer (an I/O thread) reads tail on every poll while its queue is empty, so the line is usually shared with the I/O thread's core when the main thread comes to enqueue. spscIsFull() and spscEnqueue() read and write tail_local, so every batched enqueue, including the uncommitted ones in tryOffloadFreeArgvToIOThreads(), first had to take the line back. That defeats the point of batching the tail publication. Move tail_local and head_cache to their own cache line. The consumer still only touches head, tail_cache, tail and the buffer, and the producer now only touches the shared line when it commits. The struct grows by one cache line per queue. Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com> Co-authored-by: Wangyang Guo <wangyang.guo@intel.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Review stateReady for human review. Risk: Low. Struct layout change only in Open findings: none. Backport: Not needed. Performance improvement to struct layout, not a bug fix. The same layout exists on 9.1 and 9.2 ( Updated for 2d0a762 at 2026-12-05 11:15 UTC. The bot rewrites this comment on every review. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #5761 +/- ##
============================================
- Coverage 81.80% 81.78% -0.02%
============================================
Files 202 202
Lines 106278 106278
============================================
- Hits 86941 86921 -20
- Misses 19337 19357 +20 🚀 New features to boost your workflow:
|
quanyeyang
left a comment
There was a problem hiding this comment.
LGTM and impressive. Keeping tail_local off the cache line the I/O thread polls makes sense. Thanks for including the perf c2c data! :)
Description
In
spscQueue, the producer-privatetail_localandhead_cacheshare a cache line withtail, which the io-thread polls inspscDequeueBatch()while its queue is empty. So every enqueue from the main thread (e.g.tryOffloadFreeArgvToIOThreads(), once per command) has to take the line back from the io-thread first, even for the batchedcommit = falseenqueues.This patch moves
tail_localandhead_cacheto their own cache line. No logic change.perf c2c (io-threads 16, get-10B-pipeline-100), the producer cache line before this patch:
On the main thread,
tryOffloadFreeArgvToIOThreadsdrops from 21.7% to 1.9% of cycles.Performance Boost
Didn't run a full list, just picked the benchmarks hitting
tryOffloadFreeArgvToIOThreadswith the main thread as the bottleneck (pipelined).Test Env
port 9001,bind * -::*,protected-mode no,save "",io-threads 16