Skip to main content

Module affinity

Module affinity 

Source
Expand description

CPU core affinity helpers for deterministic cross-core latency.

Pinning publisher and subscriber threads to specific CPU cores eliminates OS scheduler jitter and ensures consistent cache-coherence transfer times.

§NUMA considerations

On multi-socket systems, pin publisher and subscriber threads to cores on the same socket. Cross-socket communication (QPI/UPI) adds ~100-200 ns of additional latency per cache-line transfer compared to intra-socket L3 snoops (~40-55 ns on Intel Comet Lake).

§Example

use photon_ring::affinity;

let cores = affinity::available_cores();
assert!(cores.len() >= 2, "need at least 2 cores");

// Pin to the first core
assert!(affinity::pin_to_core(cores[0]));

Structs§

CoreId
This represents a CPU core.

Functions§

available_cores
Return the list of CPU cores available to this process.
core_count
Return the number of CPU cores available to this process.
pin_to_core
Pin the current thread to a specific CPU core.
pin_to_core_id
Pin the current thread to a core by its numeric index.