Performance Analysis
When measuring performance on multicore or NUMA systems, why are threads sometimes pinned to specific cores (setting affinity)?
- AWhen the OS migrates threads between cores, cache contents are lost or remote memory is used, making results vary
- BPinning doubles the number of cores
- CWithout pinning, the program cannot run
Show answer and explanation
Answer: A. When the OS migrates threads between cores, cache contents are lost or remote memory is used, making results vary
The OS sometimes migrates threads to other cores to balance load. The destination core's cache lacks the needed data, and on NUMA systems the thread may land on a socket far from the memory holding its data. So the same program's time varies with which cores it ran on. Pinning threads to cores and also fixing memory placement improves the reproducibility of measurements.
- A. Correct. It keeps measurement conditions consistent.
- B. The core count does not change.
- C. Programs run without pinning.