Jump to content


Photo

Processor Affinity


  • Please log in to reply
20 replies to this topic

#1 Othran

Othran

Posted 25 August 2010 - 08:16 AM

Draelor and I were chatting about this yesterday as I was converting some video from MPEG2 to MPEG4 while running Eve. I said I'd sort out some shortcuts for him and it occurs to me that some of you may find them useful too.

As some of you probably know, Eve is a single-threaded application. That means it cannot use more than one cpu core. Now what you'll find is that Windows tends not to keep it on that core but will schedule it (assign it/switch it to cores) according to what Windows perceives as "best". If the application is old enough to not be multithreaded or multiprocessor aware then this isn't optimal - it usually isn't worth setting affinity on multithreaded apps unless you know for sure the max number of cpus it'll use.

For example with Eve running and having access to all cpus it took me 42 minutes to re-encode 30 minutes of video (two pass). Once I set the cpu affinity to just one cpu for Eve, the same 30 minutes of video took 27 minutes to re-encode - the encoder maxed out the other 3 cpus where before it wasn't able to.

Anyway this is a snip of an email I sent to Draelor about how to do this :

OK I've got this sorted, Win7 is a bit stricter on syntax than Vista was.

Assume you're me - four clients, four cpus and you want each client to use a different cpu. Here's what to put in each shortcut "target" field :

Client 1 : C:\Windows\System32\cmd.exe /C start "Eve1" /normal /affinity 0x1 "C:\Program Files (x86)\CCP\EVE\Eve.exe"

Client 2 : C:\Windows\System32\cmd.exe /C start "Eve2" /normal /affinity 0x2 "C:\Program Files (x86)\CCP\EVE2\Eve.exe"

Client 3 : C:\Windows\System32\cmd.exe /C start "Eve3" /normal /affinity 0x4 "C:\Program Files (x86)\CCP\EVE3\Eve.exe"

Client 4 : C:\Windows\System32\cmd.exe /C start "Eve4" /normal /affinity 0x8 "C:\Program Files (x86)\CCP\EVE4\Eve.exe"

Notes -

1) The affinity mask is binary so I've entered the mask as a hexidecimal number. eg /affinity 0x3 would use cpu0 and cpu1, 0x5 would use cpu0 and cpu 2 etc all the way up to 0xF which uses all four cpus;

2) Windows (and most other OS) counts the cpu cores starting at 0, not 1 so a quad core would have cpu0, cpu1, cpu2 and cpu3;

2) I tend not to manually assign anything to cpu0 as its the cpu handling the base kernel and the scheduler, so in my case I assign Othran to cpu1, Slant to cpu2 and the other two to cpu3 as they don't do anything much right now;

3) When you change the shortcut target you may lose the Eve icon and get a command box icon. Just change it back by clicking "Change Icon" and point the browser at the relevant eve.exe file.


Ask if it makes no sense at all to you ;)
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#2 Granger

Granger

Posted 25 August 2010 - 08:37 AM

Nice tip Othran. You can also set affinity by opening task manager, going to processes tab and right clicking (in XP and Vista anyway, not got my laptop with Win 7 handy right now). Not sure if this works/works as well, I used to do it when dual or triple boxing but stopped bothering when I got a better spec PC. I suppose it will be well worthwhile if you want to multithread encode in the background while still playing EVE though!
"...the time should come when you have to make a choice between what is right and what is easy." - Harry Potter and the Deathly Hallows

"Except that, as is usually said of spoons, THERE IS NO SHIELD." - Lord Maldoror
"Bob Shaftoes is drenched in Hyperions" - Kil2 CCP Rise, EVE AT XI
"Cambions are like Drakes that go really fast" - MB III CCP Dolan, EVE AT XI

BASIC-042620081900
WOLFPACKS-053120081600
FLYBYS-2206081600

Posted Image

My YouTube Channel

#3 Othran

Othran

Posted 25 August 2010 - 08:57 AM

Yeah you can change affinity in Win7 the same way. Eve is about the only app I have now that I'd bother with affinity for as its single-threaded. If you don't dual-box then there's not a lot of gain really and I dunno whether I'd bother if I only had a dual-core box. With 4 cores though, Win7 tries to schedule Eve around them all and its nonsense, especially when multiple clients are involved. I used to have a great little app called "process.exe" which I used extensively on a Win2k3 colo server box to control where services were being executed (box was severely overloaded at one point). Amusingly every AV program I tried flagged the app up as malware - which I guess it could be used for !lol Oh in theory if you have an NVidia card you can force Eve to execute on a single cpu core by going into NVidia control panel->Manage 3D Settings->Eve and then turning off threaded optimisations. In theory that should force all the graphics calls from Eve to execute on one core which (again in theory) should force Eve to remain scheduled on that core. In practice (with SLI and multiple monitors) I'm not convinced it does what it claims. Probably works better with one monitor/graphics card.
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#4 Carenthor Loon

Carenthor Loon

Posted 25 August 2010 - 10:27 AM

Thanks for the tip, Othran - I've just changed my shortcuts accordingly, looking forward to seeing if it makes any difference when running multiple clients. Incidentally, I've never got much joy out of SLI with Eve - I run 3-4 clients (window mode) across two monitors, and have always got better performance disabling SLI and running 1-2 clients per card, with a monitor connected to each.
EVE is a dark and harsh world, you're supposed to feel a bit worried and slightly angry when you log in
CCP Wrangler


#5 riotrick

riotrick

Posted 25 August 2010 - 10:43 AM

I used to change the affinity manually in the task manager every now and then. But this it's much easier to setup this way. Nice tip!
Posted Image

#6 Othran

Othran

Posted 25 August 2010 - 11:09 AM

Incidentally, I've never got much joy out of SLI with Eve - I run 3-4 clients (window mode) across two monitors, and have always got better performance disabling SLI and running 1-2 clients per card, with a monitor connected to each.


Yeah the problem here is that the app is in window mode. Getting SLI focus on a window reliably was hard enough before Vista/Win7 but it WAS do-able. It still is but if you're running Aero on the desktop then the desktop itself is using "3D" features like transparency. Even with Aero disabled there's several problems with multiple monitor setups with various graphics SLI setups.

This causes a variety of issues, depending on your hardware & drivers. For me* it causes massive DPC (delayed protocol call) latency. This is so bad that it actually skews the system clock by about 5 minutes per HOUR. If you're playing Eve for a couple of hours then you can virtually guarantee you'll get traffic control & cap issues as your local time is shifting so much in relation to the server that the "old" cap problems (going to zero instantly etc) resurface.

None of this occurs when you run SLI full-screen.

It can be ameliorated by sync'ing your system time every 10 mins or so (Win7 by default does this once a week) but that's a workaround. I sync'd with Strathclyde Uni every 5 minutes when I was trying to work out what the hell was going on - I remembered the ancient "Spread spectrum clock bug" is all :)

On the wife's machine** its not so bad which makes me think its having "hybrid" graphics setup that causes a lot of the problems.

Like you I just run Eve on a single gpu. Its not like it needs SLI anyway :D

*Alienware M17x (revision 1) with 2xGTX280M and 1x9400M
** Alienware M17x (rev 2) with 2xHD5870 cards.
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#7 Draelor

Draelor

Posted 25 August 2010 - 12:30 PM

Righto, so I have only a dual core processor. What's the hex to assign one to core0 only, and the other to core1 (as per Windows listing)?
"Who the F is this knob?"

#8 Silas

Silas

Posted 25 August 2010 - 12:36 PM

Righto, so I have only a dual core processor. What's the hex to assign one to core0 only, and the other to core1 (as per Windows listing)?

You can use "/AFFINITY 1" for core 0 and 2 for core 1 (alternatively 0x1 and 0x2)

Posted Image

In wildness is the preservation of the world,

so seek the wolf in thyself


#9 Othran

Othran

Posted 25 August 2010 - 12:50 PM

Yep - as Silas said. The default for the mask is hex anyway.

The only reason I put 0x in before the mask is so its obvious to s/w & h/w peeps that it is hex. You don't need to put 0x in if you don't want to, makes no odds.

Full table for quad-core is :

0x1 - cpu0
0x2 - cpu1
0x3 - cpu0 and cpu1
0x4 - cpu2
0x5 - cpu0 and cpu2
0x6 - cpu1 and cpu2
0x7 - cpu0, cpu1 and cpu2
0x8 - cpu3
0x9 - cpu0 and cpu3
0xA - cpu1 and cpu3
0xB - cpu0, cpu1 and cpu3
0xC - cpu2 and cpu3
0xD - cpu0, cpu2 and cpu3
0xE - cpu1, cpu2 and cpu3
0xF - cpu0, cpu1, cpu2 and cpu3


The mask extends up to 0xFF for Win7 AFAIK - ie 8 cpus.
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#10 Silas

Silas

Posted 25 August 2010 - 12:52 PM

so to elaborate on that, if you're running a dual core just refer to the top of Othrans list above. 0x1 - cpu0 0x2 - cpu1 0x3 - cpu0 and cpu1

Posted Image

In wildness is the preservation of the world,

so seek the wolf in thyself


#11 Othran

Othran

Posted 25 August 2010 - 01:25 PM

One thing for the more techie amongst you to think about is the physical properties of your cpu. For example a Core2 quad cpu is pretty much (physically) two Core2 chips mounted on the same package (pinout) with some memory arbitration logic glueing them together. As such, if you have two apps that are memory bandwidth hungry it makes sense to split them between physical chips - ie put one app on cpu1 and one on cpu3. That way they're not competing for internal cache bandwidth on the two Core2 chips. Eve however is single threaded and so slow that even one Core2 cpu is massive overkill - I'd love a multithreaded Eve client but I rather suspect the current server db design would crumple in a heap (it's going the right design way - finally - now). For 99.99% of people these tweaks aren't necessary*. For the remaining 0.01% its probably not worth doing unless you've profiled the app and know what its doing. *I'm referring to general app stuff and not Eve here.
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#12 Garulf Hirgon

Garulf Hirgon

Posted 25 August 2010 - 02:40 PM

XP cavemen like me don't have many options, one which I've found works alright is http://www.mlin.net/SMPSeesaw.shtml

#13 Othran

Othran

Posted 25 August 2010 - 03:04 PM

XP cavemen like me don't have many options, one which I've found works alright is http://www.mlin.net/SMPSeesaw.shtml


Do a search for "process.exe affinity"

Thats what I used on XP/2k3 32bit boxes. Very useful.

If its XP64 then good luck finding anything that works reliably ;)
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#14 [BDEAL] B1ade

[BDEAL] B1ade

Posted 25 August 2010 - 05:49 PM

always wanted to know how to do this Automaticly, cos i run two accoutns at the same time, and its a pain doing it every time
PVP Basic Grad School of 2006
Ex Agony 2006-2007

Posted Image

#15 Baka Lakadaka

Baka Lakadaka

Posted 26 August 2010 - 03:54 AM

Yep - as Silas said. The default for the mask is hex anyway.

The only reason I put 0x in before the mask is so its obvious to s/w & h/w peeps that it is hex. You don't need to put 0x in if you don't want to, makes no odds.

Full table for quad-core is :

0x1 - cpu0
0x2 - cpu1
0x3 - cpu0 and cpu1
0x4 - cpu2
0x5 - cpu0 and cpu2
0x6 - cpu1 and cpu2
0x7 - cpu0, cpu1 and cpu2
0x8 - cpu3
0x9 - cpu0 and cpu3
0xA - cpu1 and cpu3
0xB - cpu0, cpu1 and cpu3
0xC - cpu2 and cpu3
0xD - cpu0, cpu2 and cpu3
0xE - cpu1, cpu2 and cpu3
0xF - cpu0, cpu1, cpu2 and cpu3


The mask extends up to 0xFF for Win7 AFAIK - ie 8 cpus.


The pattern will follow.

Reason being that it's binary:


01 = 0x1 - cpu0
10 = 0x2 - cpu1
11 = 0x3 - cpu0 and cpu1
100 = 0x4 - cpu2
101 = 0x5 - cpu0 and cpu2
110 = 0x6 - cpu1 and cpu2
111 =0x7 - cpu0, cpu1 and cpu2
1000 = 0x8 - cpu3
1001 = 0x9 - cpu0 and cpu3
1010 = 0xA - cpu1 and cpu3
1011 = 0xB - cpu0, cpu1 and cpu3
1100 = 0xC - cpu2 and cpu3
1101 = 0xD - cpu0, cpu2 and cpu3
1110 = 0xE - cpu1, cpu2 and cpu3
1111 = 0xF - cpu0, cpu1, cpu2 and cpu3

If you convert the Hex into binary, you can see that where there's a 1 that CPU is turned on (cpu0 being the far right and working to the left). Where there's a 0, that CPU is turned off.
Posted Image

#16 Othran

Othran

Posted 26 August 2010 - 06:33 AM

I really meant that the standard version of Win7 can handle 8 cpus rather than anything else Baka - enterprise will handle up to 64 IIRC :) You're still limited to two cpu sockets for the standard versions right enough (Home Premium I think only supports one socket).
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#17 Othran

Othran

Posted 26 August 2010 - 07:49 AM

Interesting. If you force two instances of Eve onto the same cpu then when you login the second account the first account will disconnect with the usual "Transport failed....". I KNOW I had two accounts on one cpu in 2004/5 so CCP have broken something (else).
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#18 Carenthor Loon

Carenthor Loon

Posted 26 August 2010 - 12:57 PM

Interesting. If you force two instances of Eve onto the same cpu then when you login the second account the first account will disconnect with the usual "Transport failed....".

I KNOW I had two accounts on one cpu in 2004/5 so CCP have broken something (else).

It didn't do that for me - I had two instances running on the same core last night (four in total - one on CPU1, one on CPU3 and two on CPU2).

In fact at one point I had two clients running on each of two cores, before switching one in Task Manager.
EVE is a dark and harsh world, you're supposed to feel a bit worried and slightly angry when you log in
CCP Wrangler


#19 Othran

Othran

Posted 26 August 2010 - 01:06 PM

How strange. Totally repeatable here - login account running on cpu3, login second account on cpu3 then first account disconnects and I get the "transport" message. I never have four logged in at once anyway and I cba testing to see what's causing it - got enough problems with another (non-Eve related) multiple monitor setup now too. Trying to route the HD audio over HDMI to one monitor/TV while having other monitors on DVI is not as straightforward as I'd assumed :@
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.

#20 Baka Lakadaka

Baka Lakadaka

Posted 26 August 2010 - 01:06 PM

I really meant that the standard version of Win7 can handle 8 cpus rather than anything else Baka - enterprise will handle up to 64 IIRC :) You're still limited to two cpu sockets for the standard versions right enough (Home Premium I think only supports one socket).


My point was that the pattern follows - it's the same pattern on the 72 Processor box we have at work - it's just a shitload of 1s and 0s, telling us which CPUs are on or off for a particular task. If you want all 72 processors for a task, you take the binary number with 72 1s all in a row and convert it to hex.
Posted Image

#21 Othran

Othran

Posted 31 August 2010 - 02:46 PM

Trying to route the HD audio over HDMI to one monitor/TV while having other monitors on DVI is not as straightforward as I'd assumed :@


If anyone else is looking for a nice little solution that will switch the audio over to HDMI/other output when Media Centre loads (and/or other options) then I can recommend :

Audio Renderer

Works very nicely indeed and saved me writing a script to do it :)
Today's word is :

MORAL, adj. Conforming to a local and mutable standard of right. Having the quality of general expediency.