#[repr(C, align(64))]pub struct KhlSlot {
pub packed_sequence: AtomicI64,
pub _reserved: u64,
pub items: [LineItem; 3],
}Expand description
Ring slot: Vyukov sequence (with n_items bit-packed into the
low 2 bits) + 3 LineItem payloads. Fixed shape, 64 bytes,
process-portable.
§Cross-axis fusion: n_items packed into sequence
n_items is always in 1..=KHL_ITEMS_PER_SLOT = 3, which fits
in 2 bits. Instead of paying a separate store to publish
n_items alongside the sequence number, we encode it in the low
2 bits of packed_sequence. The producer’s ONE Release-store on
packed_sequence publishes BOTH the protocol state AND the
payload count - saving one store per slot, which fuses the
K_inner axis (items per slot) with the K_gating axis
(per-slot atomic) at the slot’s cache line.
Encoding:
idx_value= high 62 bits ofpacked_sequencen_items= low 2 bits ofpacked_sequence- State:
idx_value == idx(empty) ->idx_value == idx + 1(published,n_itemsvalid) ->idx_value == idx + capacity(consumed)
Fields§
§packed_sequence: AtomicI64Bit-packed Vyukov sequence: (idx_value << 2) | n_items.
_reserved: u64Reserved 8 bytes for cache-line alignment of the items array (items start at offset 16, slot is 64 bytes total).
items: [LineItem; 3]Caller’s byte-oriented payloads. Only the first
unpack_n_items(packed_sequence.load()) are guaranteed valid.