Expand description
TLS-local observation ring.
Primitives push small observation records on every flagged op; the sidecar consumes from the ring asynchronously. Push cost is one relaxed store + branch + increment - ~3 cycles steady state.
The ring is single-producer (the owning thread) and single-consumer (the sidecar). The producer never blocks; if the ring is full, the push is dropped silently (sampling, not coordination).
Each observation carries a producer_thread_id (a process-local
sequential u32 allocated lazily per-thread via thread_id). The
sidecar’s drain folds these into per-op-kind cardinality tracking on
InstanceStats, letting policies detect multi-producer / multi-
consumer patterns directly instead of inferring them from FLAG_FULL
/ FLAG_EMPTY proxies.
Structs§
- Observation
- One observation record. 24 bytes - fits between two consecutive cache-line boundaries (3 per line, no straddling). The width carries a per-thread sequential identifier alongside the op data.
- Observation
Ring - SPSC ring used by one producer thread (push) and one consumer (sidecar).
Statics§
- ARMED_
COUNT - Process-global count of currently-armed observation rings.
Functions§
- any_
observer_ armed - True if any observation ring in the process is currently armed - one
relaxed load on the always-hot
ARMED_COUNTglobal, touching no primitive state (noself, no boxed-ring deref). The intended shape isif any_observer_armed() { self.push_<op>_cold() }where the cold method is#[cold] #[inline(never)]: the raw-handle hot path never reads the cold boxed-ring line and never grows past its caller’s inline threshold. - thread_
id - Process-local sequential thread id.