Starcraft – Any benefit to setting CPU affinity for a game

starcraft-2technical-issues

Would there be any possible benefit in setting the CPU affinity for a game? Like Starcraft 2, for example.

I've heard suggestions to do this, such as choosing real cores only (no hyperthreaded cores), choosing cores of a certain number, choosing "matching" cores, etc., and that there's benefit to be had in doing this.

But like many tips and tweaks on the interwebz, I'm wondering if this is just some digi-voodoo, or if there are actual benefits to be had (performance, stability, stutters) — even if just potential.

Best Answer

It depends on the game and the OS. Many games are not written with multi-core support in mind, but still make use of OS-level primitives that cause the OS to migrate processes between cores, which in some cases can impact performance due to cache line misses and resource allocation issues, and depending on the graphics hardware this can theoretically make a big difference, although the difference will be greater on systems with multiple distinct CPU chips rather than multi-core CPUs that share a cache and so on. Some games might even break without CPU affinity set, because they were only tested on single-core systems and make some bad assumptions about the order of operations that occur in asynchronous APIs.

The best thing to do is to try it and measure the difference, if any, and re-measure it every time there's a new graphics driver or API version update, since future versions of graphics drivers in particular can change things immensely.

That said, if a game is written to take advantage of multiple cores, then it never makes sense to set the CPU affinity on it.