Skip to main content

Module cpu_affinity

Module cpu_affinity 

Source
Expand description

Cross-platform CPU core pinning for controlled measurements.

Pinning the producer and consumer to fixed, distinct cores removes the run-to-run scheduler variance that otherwise swamps small cache-coherence effects in a 1P/1C throughput measurement. The function is best-effort: it returns false (leaving the thread on the OS default) on platforms without a supported affinity API, so a caller can report that its measurement was uncontrolled rather than silently trusting a noisy number.

Functionsยง

pin_current_thread_to_core
Pin the calling thread to a single logical core. Returns true if the affinity was actually set.