Setting CPU2 Affinity for StarCitizen.exe

Stoutman

Space Marshal
May 1, 2016
766
1,434
2,350
RSI Handle
Stoutman
Hi all,

I wrote some batch files to help set the affinity on CPU2 when starcitizen.exe is maxing out and dogging your system.

First you want to create a powershell script to actually run the commands which set the affinity. This turns off affinity on CPU2, then back on again. Just like when you use task manager to do it. Be sure to copy and name everything exactly the same as much of this is case sensitive!

You can create all these files with notepad but make sure they are named correctly. (Not ending in .txt) I run this on Windows 7, but it should run fine on Win8 and Win10.

First file is called 'StarAffinity.ps1' and it should have 3 lines:

$Process = Get-Process StarCitizen
$Process.ProcessorAffinity = 251
$Process.ProcessorAffinity = 255​

Second file is called 'start_sc.bat' and has 1 line. Save it in the same location as the first file.

powershell.exe -ExecutionPolicy Bypass -file StarAffinity.ps1​

You can run the second file after starcitizen.exe is running and it will popup a command window to run the powershell commands.

If you want to hide the command window, then you can make an optional third file.

Third file is called 'set_affinity_silent.vbs' and has 3 lines. Set the file path in it to where you saved the start_sc.bat file.

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\start_sc.bat" & Chr(34), 0
Set WshShell = Nothing​

This is some simple vbscript which hides the command prompt window from popping up. You can make a shortcut to the .vbs or .bat file on your desktop to run this. You can also set a hotkey to the shortcut to make it easier still.

I have been using this code for a while and it works great. Just make sure star citizen is up and running before you run this. It can be run when you are at the main menu.

Stoutman
 

Stoutman

Space Marshal
May 1, 2016
766
1,434
2,350
RSI Handle
Stoutman
If you have CPU2 hitting 100% a lot of the time, it can cause game performance issues. This is a common problem due to all the network portions of the code being forced onto CPU2, which is overburdening it. This is from cryengine being written for consoles.

This code is being rewritten by Franfurt's wizards, but is not in our hands yet. This is a patch that works well, if you need it.

Note: This is my understanding of what is happening and makes sense to me. Perhaps I am misinformed, but the above affinity code DOES help speed things up!
 
  • Like
Reactions: AstroSam

marcsand2

Space Marshal
Staff member
Officer
Donor
Mar 15, 2016
7,007
22,014
3,025
RSI Handle
marcsand2
If you have CPU2 hitting 100% a lot of the time, it can cause game performance issues. This is a common problem due to all the network portions of the code being forced onto CPU2, which is overburdening it. This is from cryengine being written for consoles.

This code is being rewritten by Franfurt's wizards, but is not in our hands yet. This is a patch that works well, if you need it.

Note: This is my understanding of what is happening and makes sense to me. Perhaps I am misinformed, but the above affinity code DOES help speed things up!
Then it could be handy to check each core load during game :). If no core is hitting 100% then: "If it ain't broke, don't fix it"
 
  • Like
Reactions: AstroSam

BUTUZ

Space Marshal
Donor
Apr 8, 2016
3,442
11,534
2,850
RSI Handle
BUTUZ
interesting will try it got 8 of them core things
 
  • Like
Reactions: AstroSam

ratfeast

Space Marshal
Apr 11, 2016
654
1,880
2,500
RSI Handle
ratfeast
If you have CPU2 hitting 100% a lot of the time, it can cause game performance issues. This is a common problem due to all the network portions of the code being forced onto CPU2, which is overburdening it. This is from cryengine being written for consoles.

This code is being rewritten by Franfurt's wizards, but is not in our hands yet. This is a patch that works well, if you need it.

Note: This is my understanding of what is happening and makes sense to me. Perhaps I am misinformed, but the above affinity code DOES help speed things up!
Why CPU 2, which specific cores and why, in layman's terms, please?
 
  • Like
Reactions: AstroSam

BUTUZ

Space Marshal
Donor
Apr 8, 2016
3,442
11,534
2,850
RSI Handle
BUTUZ
I think to avoid any possible confusion you need to be more clear on the definition of "CPU" and "core" and "thread"

"It runs on core 2"?

"It runs on thread 2"?
 
  • Like
Reactions: AstroSam

marcsand2

Space Marshal
Staff member
Officer
Donor
Mar 15, 2016
7,007
22,014
3,025
RSI Handle
marcsand2
I think to avoid any possible confusion you need to be more clear on the definition of "CPU" and "core" and "thread"

"It runs on core 2"?

"It runs on thread 2"?
It doesn't matter. An AMD can have up to eight cores, an Intel can have 2, 4 or 6 cores with hyper threading, which will be 4, 8 or 12 cores.This all is hardware. Software doesn't run on hardware, software runs on an operating system. Windows tells me I have CPU 0 to CPU 7. Software that runs on Windows also can get access to CPU 0 to CPU 7.

upload_2016-5-8_22-0-42.png


Above is a screenshot of the CPU load while running PTU. It shows that my CPU 2 is working hard, altough not yet 100%. So, the Star Citizen software uses CPU 2 more then the other 7 CPUs.

The method that @Stoutman describes takes care of it that the Star Citizen software isn't focused on CPU 2 anymore. I still must test it and when I'm done, I will post another screenshot of my CPU load.
 

BUTUZ

Space Marshal
Donor
Apr 8, 2016
3,442
11,534
2,850
RSI Handle
BUTUZ
Interesting - yet you're overall CPU use has gone down by 4%. Does that mean the game is running 4% slower?
 
  • Like
Reactions: AstroSam

marcsand2

Space Marshal
Staff member
Officer
Donor
Mar 15, 2016
7,007
22,014
3,025
RSI Handle
marcsand2
nope, utilization is real time. 60% and 56% are on the moment I took the screenshot. Load is never a straight line.... never say never, if PC is of then you will have a straight line :D, although you can't see it ;)
 
  • Like
Reactions: AstroSam

BUTUZ

Space Marshal
Donor
Apr 8, 2016
3,442
11,534
2,850
RSI Handle
BUTUZ
EES INTERESRTING VERY INTERESTING.

I think I will do some CPU testing now!
 
  • Like
Reactions: AstroSam

Stoutman

Space Marshal
May 1, 2016
766
1,434
2,350
RSI Handle
Stoutman
It took me many hours to research how to do this. Microsoft does not share this type of stuff very well.

You can also set TaskScheduler to run the bat file automatically when starcitizen.exe starts up, but that is a whole new nightmare to setup...
 
  • Like
Reactions: AstroSam

Stoutman

Space Marshal
May 1, 2016
766
1,434
2,350
RSI Handle
Stoutman
It is not speeding things up, it is forcing things to be distributed among the CPUs more evenly. Thus preventing CPU2 from maxing out and lagging the game.

This is very apparent when you are also streaming on the same system, like I was when I decided to figure this all out.
 
  • Like
Reactions: AstroSam

marcsand2

Space Marshal
Staff member
Officer
Donor
Mar 15, 2016
7,007
22,014
3,025
RSI Handle
marcsand2
I got another one for you:
- rename starcitizen.exe
- make a small program that runs the renamed starcitizen.exe, name that program: starcitizen.exe. The star citizen loader will run your program instead of starcitizen.exe
- let your batch file run by the program after it started starcitizen.exe
should work in theory ;)
 
  • Like
Reactions: AstroSam

BUTUZ

Space Marshal
Donor
Apr 8, 2016
3,442
11,534
2,850
RSI Handle
BUTUZ
CPU STD.jpg
Hmm not working for me. Windows 10 here. I wonder if theres something different.

PS. Herre's a before: Poor CPU 2!!!
 
  • Like
Reactions: AstroSam

Stoutman

Space Marshal
May 1, 2016
766
1,434
2,350
RSI Handle
Stoutman
Windows 10 may not recognize the commands? I'll try it on my streaming system, which is win10 and my old gaming rig.
 
  • Like
Reactions: AstroSam
Forgot your password?