Processor Affinity

Processor Affinity

Postby Nanban Jim on 17 Sep 2011 20:22

I could not find this on a search, so I'm putting it here.

Bottom Line Up Front: You can't get Stalker to use all of your CPUs in a multi-core system. Start Stalker, open Task Manager, right-click on the process and choose Set Affinity. Un-check all the cores on your first physical CPU (in an Intel Q6600, this is CPU 0 and CPU 1, leaving CPU 2 and CPU 3 available). Leave the rest checked. Play STALKER and enjoy somewhat improved load distribution and performance. Works to a lesser extent on systems with a single physical CPU but multiple cores (eg Core 2 Duo) by removing affinity for CPU 0.

The Long Version: For a few years now I've been running a Q6600 (Core 2 Quad), which is essentially a pair of Core 2 Duos strapped together (this is relevant). I'd noticed on XP that the first logical CPU (CPU 0) would tend to get the lion's share of the tasks. Of the others, the second logical CPU would get about double the negligible amount that the last 2 would use.

So of course, I'd open up Task Manager, find a few important processes, right click, Set Affinity, and pick a core. I'd put my browser on 3, my IMs and MU* client on 2, and a couple others.

... every. Damn. Reboot.

I found on a Tom's Hardware thread this utility, http://code.google.com/p/pamanager/ , which manages processor affinity for applications on a recurring basis. That was awesome. Windows 7 was supposed to be better about automagically doing this sort of thing, and it is--as far as that goes. We've had ADA since 1980, but for some reason programs are compiled with a preference for the first logical core quite often, so you get bloat on CPU 0. You can see this with STALKER ShOC and CS, and probably CoP (don't have it, but it's a good bet). You start it up, leave Task Manager running, and CPU 0--the first logical core of the first physical core--gets most of the work.

What I'd also found is that if you uncheck CPU 0, then CPU 1--the first available logical core of the first physical core--will get most of the workload of the game, just like CPU 0 did. Frustrating, it's got 3 cores to work with, c'mon, use them!

Ah, but that's where that relevant bit up top comes in: The process will prefer the first physical CPU available in all cases, but will trust the OS a bit more if the first physical CPU is unavailable! This is true of the X-Ray engine, and most processes I've found. This is true on XP and Windows 7 64-bit Pro (as well as the public release candidate of Win7x64).

What does this mean to you? Well, the Q6600 is a pair of Core 2 Duos. The first Core2Duo (physical CPU 1) is logical CPU 0 and logical CPU 1. The second is logical CPU 2 and logical CPU 3. Look at that bit in bold italics.

That's right. If you un-check CPU 1 and CPU 2 on a Q6600--in other words, if you make the first physical CPU unavailable--then the process puts its management more firmly in the OS's hands. You will see a more even load distribution across logical CPU 2 and logical CPU 3, the entire second physical CPU. With only logical CPU 0 un-checked, the first physical CPU is still available (via logical CPU 1), and the process will prefer that. With both cores of the first Core2Duo (the first physical CPU) unchecked, thus unavailable, the OS takes over and says "I'll handle threading and junk, you just send me tasks" and distributes them across the next available physical processor. Since the OS is handling it transparently, the process can't horn in and insist they're all run on one logical processor too. You get better performance and more even load distribution.

CAVEATS: I have not tested this on other OSes. Processor Affinity Manager does not work on Win7x64 Pro. I do not know how this works out on other CPUs. If you have more than 2 physical cores, I do not know if removing affinity for the first physical core will distribute the load across the other physical cores, or just the next available one. If it's just the first available one, since everything wants to run on the first physical core then you're still likely to see better performance. Likewise, if you just have a dual-core, at least the X-Ray engine will be sitting on the second logical core if you disable affinity for CPU 0, thus improving your load balancing a bit.

Good hunting, Stalkers.

PS: You break your machine doing this, and it's on you. Damn lawyers. >.<
Nanban Jim
New Member
 
Posts: 6
Joined: 07 Sep 2011 00:12

Re: Processor Affinity

Postby rockingmtranch on 18 Sep 2011 21:22

I have a duel core and I swear that made a difference. Thanks :-bd
LINUX! Don't fight it. You will be assimilated!
----------------
Gulf War Vet--2nd Squadron, 2nd ACR, Fort Polk, LA
User avatar
rockingmtranch
Moderator
 
Posts: 1368
Joined: 13 Sep 2008 02:39
Location: White Hills, Arizona

Re: Processor Affinity

Postby Nanban Jim on 18 Sep 2011 22:06

Quite welcome! That would be due to it running on the second logical CPU, while "everything" else is lining up for the first. (Which I'm sure you understood, but y'know, someone could be reading this before coffee.)

As a note, I found this last night and it seems to do the trick: http://bitsum.com/prolasso.php

It has the ability to run just the engine as a service, instead of loading the whole darn GUI. Seems pretty in-depth, might take some tuning, but yeah there ya go.
Nanban Jim
New Member
 
Posts: 6
Joined: 07 Sep 2011 00:12

Re: Processor Affinity

Postby rockingmtranch on 19 Sep 2011 19:42

Thanks. That looks a bit complicated and it's another program on my computer. I'll just manually do it for now. If that gets tiring then I'll come back here.
LINUX! Don't fight it. You will be assimilated!
----------------
Gulf War Vet--2nd Squadron, 2nd ACR, Fort Polk, LA
User avatar
rockingmtranch
Moderator
 
Posts: 1368
Joined: 13 Sep 2008 02:39
Location: White Hills, Arizona

Re: Processor Affinity

Postby ket on 12 Oct 2011 02:50

There is another way which some may prefer. Download a program called Regcleaner, once installed click the "startup" tab. Chances are you will have a huge long list of applications starting with Windows hogging CPU and memory resources. Simply remove all you don't need, restart your PC, and viola. You have just freed up CPU and memory resources.
Mobo: MSI X570 Tomahawk
CPU: R7 3700X @ 4.4GHz 1.3v
RAM: 2x16GB Klevv BoltX 3600MHz 16-20-20-35
GPU: Powercolor 6800XT Red Devil
Sound: Asus Xonar DX 7.1 PCI-E, Realtek ALC1200
HDD: 250GB & 500GB nVME 3.0 M.2 drives, 2TB Seagate Barracuda, Sata3 64MB Cache, 250GB Hynix SL301
Opticals: DVD-RW, Blu-Ray
PSU: eVGA 1000w G2 Supernova
Case: NZXT Phantom 530

STALKER: Singularity (SIN) homepage
User avatar
ket
Senior Resident
 
Posts: 1262
Joined: 14 Sep 2008 11:57
Location: The solar system

Re: Processor Affinity

Postby Nanban Jim on 31 Jan 2012 06:55

A useful tip, Ket, but not quite the same thing. That just removes some of the stuff running on core 0. This is about bypassing the queue for core 0 and going to a core that doesn't get used as often. It's like finding out that everyone at the grocery store lines up for lane 1, while you realize you can just go to lane 2. :D
Nanban Jim
New Member
 
Posts: 6
Joined: 07 Sep 2011 00:12


Return to Problems & Solutions

Who is online

Users browsing this forum: No registered users and 0 guests

cron