Weird lag spikes until I remove affinity from specific cores?

Modified

I was experiencing weird lag spikes and noticed the game was spiking to max on the first 4 cores on my CPU intermittently. So I removed affinity from those cores for the game process, and the load seemed to spread out among the rest of the cores more evenly and made the game run buttery smooth. Anyone else experienced this?

Before: https://i.imgur.com/tXOmtfJ.png

After: https://i.imgur.com/toqjCor.png

Posted Jan 8, 2022, 7:36 AM UTC

136
Apoll76•

One of the reasons I use Linux playing X4 is this. The game spreads out on the 12 cores of the 3900X and now the 5900X without the bottlenecking at first 2-4 cores on Windows.

I will give it a try tonight and let you now when boot on windows.

5
ben_wuz_hear•

Is this something that happens on other games also?

2
Apoll76•

Nope. X4 is the only game using all cores even on a 5950X and 3970X, the background simulator is unique

2
FluffyMcBunnz•

To be honest the screenshot just looks like it's moved to two other cores but screencapping those graphs was never going to be the definitive proof for anything. Time to try it out then!

On my i7-11700k, X4 set to the default affinity for all cores, when it runs it uses 4 cores mostly and seems to only lightly use the rest, going by the graphs (and by me having killed off almost all other software to keep it sort of readable). In normal play, spikes do happen.

I tried setting affinity to all the even numbered cores to see if this would indeed help. I think this should mean it doesn't use the virtual cores from the hyper-threading tech though I'm not positive that it's showing the two virtual cores for each physical one as subsequent cores?.

It loads the two cores it was already on to 100% each and then it does seem to load the other allowed cores more than it did before, but the lag spikes get worse, and especially noticeable when you give orders to large groups of ships at once or if you enter a busy sector (or a big fight, which the Xenon kindly provided for testing purposes and also because they're bastards who want to hurt my station).

I also tried giving it just half the cores (1-8) or only the odd ones to see if I could figure out if that matters, and it doesn't really. Performance is sort of same-ish with no real noticeable distinction and all of them are the same most of the time and worse in high density sectors as when just giving it all 16 cores. Even though then it does seem to load most of the workload onto 4 of the 16, those 4 never really hit 100% for long and if you let it show you a longer span, say 4 minutes instead of 60 seconds, you can clearly see a spike on all 16 cores between the game being paused and alt-tabbed out of, vs it being active and playing. That spike goes up for the four most loaded ones when you turn on SETA, and the other 12 do all slightly incline, but the use on those is still quite low.

When you cut off specific cores, two of them hit 100% and stay there, and I suspect that's probably showing that cutting cores creates a bottleneck for the game. That gets drastically worse when you turn on SETA because then you REALLY notice it's struggling.

So for me, leaving all cores on is the best setting.

2
hahanixx•

That’s correct

1
Fluffy_Jello_7192•

Like 99.999% of the time someone thinks they're smarter than the Windows CPU scheduler (by manually screwing with CPU core affinity) it ends up being the placebo effect or confirmation bias.

None of your lag spikes are caused by your CPU, or the Windows CPU scheduler. Its about 100x more likely to be caused by other shit running in the background (probably a shitty Electron app that's eating 2+ GB of RAM and tons of unnecessary CPU cycles for no good reason - looking right the fuck at you Discord) while you're gaming, or the fact that you have too many mods or conflicting mods running.

X4 runs rock solid on my 6700k build, my 10700k build, and my 11900k build, all without ever screwing with processor affinity.

1