Any benefit to setting CPU affinity for a game?
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
Day9 claimed back in 2010 that it has some effect. In some other casts he said that he invested a lot of time into tweaking his setup, because he did not have a lot of money, his computer kept overheating and everybody wanted him to stream in HD.
Some time ago he gave a Video Streaming Tutorial
His setup is as follows
- Encoder CPU: 0,1,2,3
- Starcraft 2 CPU: 4,5
- Screen Capturing Software CPU: 6,7
As long as the CPUs are going to be used all the time it makes sense that the same programs should keep using them to save context switches.
Then again it was back in 2010 and maybe the operating systems do a better job of this.
I would give it a try to see if the results are better, but only if you need your computer to do a lot of computation at the same time.
If you just play Starcraft, without streaming, it is easier to disable, close or suspend any other applications or services that might drain a lot of resources.
Pictures about "Any benefit to setting CPU affinity for a game?"



Should I set CPU affinity?
Processor Affinity is useful if you have a heavy program like video rendering. When you dedicated a core for the video editing program, it ensures that the core of the processor is always dedicated to the task. It improves performance because it reduces reduce cache problems as there is no delay with a dedicated core.Should I set affinity for games?
Setting affinity is good if you have an old game that will crash if you OS tries to spread its single-core usage over multiple CPU cores.Does CPU affinity affect performance?
CPU affinity protects against this and improves cache performance. A second benefit of CPU affinity is if multiple threads are accessing the same data, it can make sense to bind them all to the same processor. Doing so guarantees that the threads do not contend over data and cause cache misses.What does CPU affinity do?
Processor affinity or CPU pinning enables applications to bind or unbind a process or a thread to a specific core or to a range of cores or CPUs. The operating system ensures that a given thread executes only on the assigned core(s) or CPU(s) each time it is scheduled, if it was pinned to a core.FPS Boost using different CPU Affinity Settings?
More answers regarding any benefit to setting CPU affinity for a game?
Answer 2
This, at best, is a micro optimization and if you see any measurable performance improvements in game, you'll likely affect other aspects of your system. Remember that while you are running the game, windows services and other processes are still working.
So, rather than attempting to do something like setting the processor affinity, you'd be better off closing as many other applications as possible to keep the CPU (and memory) as free as possible.
I'd expect you'll see greater gains here (although still minor) with much less work.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Martin Lopez, Martin Lopez, Dave Morgan, Pixabay
