You can create a shortcut to assign affinity.
X:\Windows\System32\cmd.exe /C start /affinity Y game.exe
Y is hexadecimal and is a bit mask:
0x1 - 0001 - Core0
0x2 - 0010 - Core1
0x3 - 0011 - Core1 & Core0
0x4 - 0100 - Core2
0x5 - 0101 - Core2 & Core0
0x6 - 0110 - Core2 & Core1
0x7 - 0111 - Core2 & Core1 & Core0
0x8 - 1000 - Core3
0x9 - 1001 - Core3 & Core0
0xA - 1010 - Core3 & Core1
0xB - 1011 - Core3 & Core1 & Core0
0xC - 1100 - Core3 & Core2
0xD - 1101 - Core3 & Core2 & Core0
0xE - 1110 - Core3 & Core2 & Core1
0xF - 1111 - Core3 & Core2 & Core1 & Core0
Answer from Hasan Manzak on Stack ExchangeYou can create a shortcut to assign affinity.
X:\Windows\System32\cmd.exe /C start /affinity Y game.exe
Y is hexadecimal and is a bit mask:
0x1 - 0001 - Core0
0x2 - 0010 - Core1
0x3 - 0011 - Core1 & Core0
0x4 - 0100 - Core2
0x5 - 0101 - Core2 & Core0
0x6 - 0110 - Core2 & Core1
0x7 - 0111 - Core2 & Core1 & Core0
0x8 - 1000 - Core3
0x9 - 1001 - Core3 & Core0
0xA - 1010 - Core3 & Core1
0xB - 1011 - Core3 & Core1 & Core0
0xC - 1100 - Core3 & Core2
0xD - 1101 - Core3 & Core2 & Core0
0xE - 1110 - Core3 & Core2 & Core1
0xF - 1111 - Core3 & Core2 & Core1 & Core0
If by "non software" you mean not requiring additional software, there is. You can run the program from a command script and use the affinity switch "Start /AFFINITY 20 process.exe"
/AFFINITY 20treats the 20 as a hexidecimal number, with a binary equivalent of 100000, which sets affinity to core 5 out of 0-5 on a 6 core processor. A similar hex mask will let you disable a specific core, such as E, which only runs the process on cores 1-3 out of 0-3 or 0-5.
starcraft 2 technical issues - Any benefit to setting CPU affinity for a game? - Arqade
PSA to anyone struggling with performance: Change the affinity
Disabling a core through Set Affinity. What is it exactly?
ELI5: Why does disabling CPU affinity starting with Core 1 and every other core improve the game's performance dramatically?
How does setting CPU affinity interact with multi-core processors?
Can setting CPU affinity improve performance for gaming?
Does setting CPU affinity affect all users on the computer?
Videos
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.
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.
I've been struggling with horrible performance (dropping to unplayable levels in certain areas even on low graphics settings) but finally found a solution not posted anywhere else to my knowledge. I only decided to try it after reading that UE4 is horrible at multithreading and after confirming it worked, decided to post here in hopes that it can help someone else too.
In the task manager, click the "Details" tab and right click on the game, then select "set affinity". In the Processor affinity window, uncheck all odd numbered CPU's. Leave CPU 0 and all even numbers checked.
If you're playing on an oculus device, locate the "Oculus Debug Tool" and disable a setting called "(PC) Asynchronous Spacewarp".
I'm now able to play with all settings on high with no noticeable frame drops, hopefully this will help you too.
My set-up: RTX 3070 TI - i9 9900k - 32gb ram - Quest 3 via link
I do this every game session and it seems to work when I check my FPS. I forgot where I read this. I tried the script that automates the process but it always ends up in an error so I do it manually.
Using Compatibility with Win95 or 98 (XP\7 won't help) should force the game to run on a single core .
Failing that, if you are able to Alt\TAB out of the game and back in successfully go to Task Manager>Details tab and
R\click on the Games title>Set Affinity and select cpu 0 .
Still not go ? You may want to enquirer with GOG support about running DOS based games on cpu's with more than four cores.
(I haven't had any issues with the few DOS based games I have when using a quad core cpu. )
It may also be possible to use a batch file to launch the game with a single core, but I wouldn't know how to set it up.
What game, btw ?
.
"right click the game title in task manager onprocesses and set affinity, but this option doesn't exist for me."
- That's why I underlined Details tab, but I may have done that edit after you read my post.
If I remember correctly the affinity option was in processes on Win7.
I play a game called Black Desert. It's a badly-optimized game so it needs some "special" setting.
I intend to follow this guide and set CPU affinity on the game to get better performance.
Will this harm the age of my CPU? Looks like the guide recommended to use 3 threads only.
I'm using ryzen 5 2600x
Process Lasso from BitSum
I have been struggling with this for ages. then a friend pointed me to this.
how he found it, I have no idea.
but process lasso is a very simple tool, that just works. I don't know why Microsoft hasn't allowed us to set affinity/priority on a permanent level, or why nobody seems to know [yet] about this tool, but I had to tell someone.
I kept ending up on dead forums that didn't do what I needed, and I couldn't resurrect them or reply now that I found the tool, but here you go.
I hope I help at least one future user!
Hi waihong_63,
Welcome to Microsoft Community.
For a way to set CPU affinity for an application, I found two threads shared by a user in the community. There is information about changing the CPU affinity through the registry and shortcut parameters, which I think will help you.
How to Permanently Set Priority & Affinity With Shortcut File
How to Permanently Set Priority Processes Using Registry Editor
In the case of an application that can only run with a small number of CPU cores, there is an upper limit on the number of cores that the application can support by default (this needs to be confirmed based on information provided by the application's developer), but it can still be forced to change through methods such as the registry.
Disclaimer: Generally, modifying registry subkeys or work group is intended for advanced users, administrators, and IT Professionals. It can help fix some problems, however, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For further protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click here to view the article.
Please feel free to let me know if you got any further updates, thanks.
Best Regards,
Manson - MSFT | Microsoft Community Support Specialist
Setting affinity does do something, but you'll never want to use it.
Setting the CPU affinity forces Windows to only use the CPU (or cores) selected. If you set the affinity to a single CPU, Windows will only run that application on that CPU, never on any others.
Windows automatically puts run applications on the least-busy processor, so limiting it to a single CPU doesn't let Windows do its job. Even if CPU/core 1 is busy running other applications, Windows won't be able to run an application with affinity set on CPU/Core 2.
Really the only reason you would want to do that is to run an old application that doesn't work correctly when running on a multi-CPU/Core system.
This is a very useful feature in certain scenarios. Let's say you have a multi-threaded application that tends to either be idle or aggressively grabbing 100% of every CPU for several minutes, doing searches, builds, etc. Let's call this application "eclipse."
Let's also say that while you're working on this application, you have a bunch of other applications that have modest cpu requirements, but are essentially real-time applications. For example, while you're using Eclipse and it is randomly kicking off builds or doing gwt compiles, you're also using your computer to stream music or perform research in a browser window (for example, researching the cause of a build problem). Sure, you will not die if your music skips or your browser stops responding, but it's annoying.
What affinity lets you do is confine your cpu eating app to 7/8 cores so that everyone else is guaranteed access to a relatively unused cpu and you don't constantly have to deal with stuttering and interruptions to the usability of everything else on your computer while eclipse is grinding away.
in powershell:
$instances = Get-Process
foreach ($i in $instances) { $i.ProcessorAffinity=1 }
will make most processes run on first core (core 0 in task manager). Yes it will throw quite many "Access denied" errors for processes it can't change affinity for. just ignore it... for the rest it works.
and then manually or with command set your game to the desired cores, like:
(Get-Process -name doom).ProcessorAffinity = 14
to set your 'doom' game to run on remaining 3 cores on 4 core CPU.
A few other methods to force Windows to run applications on only one core is answered here. That could free up your other three cores for your game. And how to set the affinity for this one manually via taskmgr or cmdline answered Keltari with other useful hints where performance bottlenecks could be.
the reason why ryzen can't compete with even the older intels is because ryzen's core are divided up by 2 CCX's in your processor chip, and ccx sucks at communicating with each other.
So if you assign csgo to JUST use 4 of the physical threads in the latter CCX ie 8 10 12 14 (for some reason the first 4 doesn't perform as well) it will feel good to play cs again.
so here's my hour wasted using ryzen 1700 @ 3.7ghz, 2x 8gb 2933 ram, 1080 graphic card, csgo on 1024x768 all low
my current launch options: -novid -nojoy -console -freq 144 +mat_queue_mode 2 -d3d9ex -threads 4***(obviously this was changed around testing different affinity counts, but they say its a snakeoil so who knows)***
8c/16t smt on w/ no affinity assignment: 296.40
8c/8t smt OFF w/ no affinity assignment: 349.12
8c/16 smt on w/ csgo on 0 8 10 12 14: 386
8c/16 smt on w/ csgo on 0 2 4 6 : 398.14
8c/16 smt on w/ csgo on 8 10 12 14: 418
proof and more gruesome visual aids for each scenarios these numbers do not represent real game performance. I only.used the map because its consistent every time and dm thing is stupid because its going to be different every other time just view the benchmark map fps to compare relative increase from the baseline. you can always try it out for yourself, if it sucks it only takes 5 seconds to revert back.
presumably this would also work in other dual core intensive games like sc2 but i dont play those other than cs. and it should work the same for 1600/2600s and other ryzens.(except they are 3+3 instead of 44)
howto easy mode: [set affinity on task manager] (https://imgur.com/a/4BpHSLu)
how to assign permanently: download process lasso
tl;dr volvo ryzen optimization update when
here's some technical mumbo jumbos
toms hardware with inter/intra ccx latency chart (scroll down)
anadtech's ian cutress briefly going over ryzen's design on his ryzen 1200/1300 review
AMD decided to go with the 2+2 arrangement for the quad core Ryzen parts, following on from the 3+3 arrangement on the hex-core Ryzen 5 CPUs..... The downside is core-to-core latency, as the CPU would have extended latency between neighboring cores and those in the different CCX, and it goes back to the non-uniform memory access argument with the Ryzen 7 CPUs.
for some reason the first 4 doesn't perform as well
Most likely windows is assigning processes to those threads first, so by sticking to the second ccx, there is less competition for those resources.
tl;dr volvo ryzen optimization update when
Hopefully soon since a lot of CS:GO teams/players are really pushing AMD in the competitive scene like Fnatic and S1mple.