Skip to main content

Module observation

Module observation 

Source
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.
ObservationRing
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_COUNT global, touching no primitive state (no self, no boxed-ring deref). The intended shape is if 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.