Thread affinity
Technique of pinning a thread to a specific CPU core to preserve cache locality and reduce migration overhead.
The OS scheduler places threads on CPUs as it sees fit—a thread might jump cores several times per second. Each migration flushes its L1/L2 caches and requires reloading from slower L3 or main memory. For sensitive code, this overhead can exceed the computation itself. Thread affinity forces the OS to keep a thread on the same core as long as possible.
On many-core systems (especially NUMA), affinity can save more than tenfold in performance overhead. The scheduler can also pin threads to NUMA nodes where their data already resides. The tradeoff: if that core is overloaded, affinity can make things worse. Most high-performance systems explicitly pin threads via OS APIs (sched_setaffinity on Linux, SetThreadAffinityMask on Windows).