pub struct RingHeader {
pub magic: u64,
pub capacity: u64,
pub slot_size: u64,
pub epoch: AtomicU64,
pub producer_seq: AtomicU64,
pub consumer_seq: AtomicU64,
/* private fields */
}Expand description
Header layout: three cache lines so the two hot counters never
false-share. Line 0 is read-mostly metadata (plus the
rarely-written epoch); producer_seq and consumer_seq each get
their own line. Every producer CASes producer_seq and every
consumer CASes consumer_seq; co-locating them on one line made
each side’s CAS invalidate the other side’s copy, serializing the
producer and consumer coherence traffic under contention. The SPSC
ring separates head/tail for exactly this reason.
Fields§
§magic: u64§capacity: u64§slot_size: u64§epoch: AtomicU64Epoch counter; advanced by the watchdog every scan tick. Heartbeats compare against this to detect liveness. Read-mostly from the ring’s perspective, so it shares the metadata line.
producer_seq: AtomicU64Producer-owned enqueue counter; sole occupant of its line.
consumer_seq: AtomicU64Consumer-owned dequeue counter; sole occupant of its line.