pub struct Sidecar { /* private fields */ }Expand description
The sidecar singleton. Internally a pool of one NodeSidecar per
detected NUMA node; each node has its own scanning thread + Vec of
registered primitive instances. Registration routes by
current_numa_node() so cross-NUMA cache traffic on the scan path
stays minimal. InstanceId encodes (node_index, slot) so unregister
- stats can find the right node’s vec.
Implementations§
Source§impl Sidecar
impl Sidecar
Sourcepub unsafe fn register_raw(
&self,
header: NonNull<HandshakeHeader>,
ring: NonNull<ObservationRing>,
instance: Option<NonNull<dyn AdaptiveInstance>>,
policy: Box<dyn Policy>,
) -> InstanceId
pub unsafe fn register_raw( &self, header: NonNull<HandshakeHeader>, ring: NonNull<ObservationRing>, instance: Option<NonNull<dyn AdaptiveInstance>>, policy: Box<dyn Policy>, ) -> InstanceId
Register a primitive instance.
§Safety
header, ring, and (when provided) instance must remain
valid until unregister(id) returns for the returned id.
Prefer SidecarBox which enforces this invariant automatically.
Sourcepub fn unregister(&self, id: InstanceId)
pub fn unregister(&self, id: InstanceId)
Remove a registered instance.
Blocks until any in-flight scan iteration finishes, so the caller can safely drop the underlying header/ring memory immediately after this returns.
Sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
Currently-registered instance count.
Sourcepub fn max_instances(&self) -> usize
pub fn max_instances(&self) -> usize
Configured maximum simultaneously-registered instances. See
DEFAULT_MAX_INSTANCES for the default and
Self::set_max_instances to change it.
Sourcepub fn set_max_instances(&self, cap: usize)
pub fn set_max_instances(&self, cap: usize)
Raise or lower the instance cap. Intentional heavy-registration
workloads (e.g., a server that legitimately wants > 10,000
adaptive primitives live at once) should call this once at
startup. The cap is per-process; the global Sidecar inherits
it via global().
Sourcepub fn stats(&self, id: InstanceId) -> Option<InstanceStats>
pub fn stats(&self, id: InstanceId) -> Option<InstanceStats>
Snapshot the stats for a registered instance.
Sourcepub fn scan_now(&self)
pub fn scan_now(&self)
Force one scan iteration synchronously across all NUMA nodes. Useful for tests where we don’t want to wait for the poll interval.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of NUMA-pinned sidecar threads in this pool.