Expand description
Sidecar control plane for adaptive primitives.
One background thread per detected NUMA node; each thread polls the registered primitive instances bound to its node:
- Drains each instance’s
ObservationRinginto a per-instanceInstanceStatsaccumulator. - Asks the instance’s
Policywhether a strategy migration is warranted. - If yes, calls
HandshakeHeader::set_tagto install the new strategy.
Heavy migrations (data swap) are NOT handled here; primitives
that need them invoke their own migration logic from within the
policy callback (e.g. subetha-cxc::AdaptiveIpc::migrate_to).
§Safety model
Registration takes raw pointers to the user’s HandshakeHeader and
ObservationRing. The contract is:
- The user must keep these alive until
unregisterreturns. unregisterblocks until any in-flight scan finishes, so the user can drop the underlying memory immediately after.
The SidecarBox<T> wrapper enforces this contract by holding a
Box<T> (stable address) alongside an auto-unregistering
SidecarHandle.
Modules§
- bench_
safe - Bench-safety helpers and the cardinal pattern for adaptive primitive benches.
Structs§
- Fixed
Policy - Convenient policy that always returns the same tag (testing).
- Instance
Stats - Aggregated statistics for one registered instance.
- NoMigration
Policy - Convenient policy that never migrates (default for primitives that haven’t shipped their adaptation logic yet).
- Sidecar
- The sidecar singleton. Internally a pool of one
NodeSidecarper detected NUMA node; each node has its own scanning thread + Vec of registered primitive instances. Registration routes bycurrent_numa_node()so cross-NUMA cache traffic on the scan path stays minimal. InstanceId encodes (node_index, slot) so unregister - Sidecar
Box - Boxed primitive + auto-unregistering sidecar handle.
- Sidecar
Handle - RAII handle that auto-unregisters its instance on drop.
Constants§
- DEFAULT_
MAX_ INSTANCES - Default hard cap on registered instances. Sized to fail fast on
the “bench creates a SidecarBox per
b.iter()” mistake, which exhausts the host near 94k registrations: this cap refuses an order of magnitude before that, while leaving room above the 10..1000 range production workloads sit in. - MAX_
TRACKED_ THREADS_ PER_ KIND - Maximum distinct producer thread ids tracked per op kind. Picked to be cheap (484 = 128 bytes per instance) while sufficient for the policy decisions that read this - once cardinality crosses 1, the policy migrates regardless of the exact count.
- N_
OP_ KINDS - Number of op_kind slots the InstanceStats tracks. Primitives use
op_kindvalues 1..=N to identify per-op-kind buckets (e.g., load vs store forAdaptiveCell; insert/get/remove/snapshot for the snapshot map). Op kind 0 is reserved for “unspecified”.
Traits§
- Adaptive
Instance - Trait implemented by adaptive primitive instances that opt into sidecar observation. The Box guarantees stable addresses for the header and ring.
- Policy
- Decides when and how to migrate a primitive instance’s strategy.
Functions§
- current_
numa_ node - Per-NUMA-node sidecar sharding scaffolding. The default global
sidecar handles all instances; multi-sidecar deployment with
per-NUMA pinning would spawn one Sidecar per node and route
registrations by spawn-thread affinity. The detection function
numa_node_countsurfaces the topology; the routing layer plugs in here when load testing on a multi-socket host motivates it. - global
- Get the process-wide sidecar singleton.
- numa_
node_ count - Number of NUMA nodes detected on this host. Used by the (in-progress) per-NUMA sidecar sharding to decide how many sidecar threads to spawn.
Type Aliases§
- Instance
Id - Stable identifier for a registered primitive instance.