3 ms·
Pinning threads to cores with affinity is another technique that should be used with caution. Under normal circumstances the kernel will run the same thread on
by exDM69 9y ago
Pinning threads to cores with affinity is another technique that should be used with caution. Under normal circumstances the kernel will run the same thread on the same core as much as possible because CPU migration is expensive.
Setting CPU affinity will ensure that you always get the same core, but it might not increase performance and could adversely affect other parts of the system.
CPU affinity is a good fit for continuously running things like audio processing or game physics or similar. It's not good when threads are blocked or react to external events.
In most cases it's just unnecessary because the kernel is pretty good in keeping threads on cores anyway.