cancel
Showing results for 
Search instead for 
Did you mean: 

Processor Affinity

Moderator
Moderator
Posts: 18,074
Thanks: 2,616
Fixes: 192
Registered: 06-04-2007

Processor Affinity

As Handbrake is taking all the 6 cores to the max even with priority set to Below Normal I thought I'd reduce it from using all 6 cores to using just 4 of them which has helped in making other programs run better once more. But I was wondering does it matter which cores I select for any application to use/not use? Do the lower numbers take a higher precedence over the rest or vice-versa?

Forum Moderator and Customer
Courage is resistance to fear, mastery of fear, not absence of fear - Mark Twain
He who feared he would not succeed sat still

14 REPLIES
Community Veteran
Posts: 5,238
Thanks: 1,130
Fixes: 3
Registered: 06-11-2014

Re: Processor Affinity

Unlike the politics and social standings of most countries, CPU cores are all equal, so despite their number in the chain, it doesn't matter which get used, they all do the same thing, so you could have cores 1 thru 4 doing the Handbrake work, and 5 & 6 doing other things as you have got there, or you could have 1, 2, 5 & 6, doing Handbrake's tasks, and 3 & 4 doing everything else, or you could have 6 things going at once each using a separate core, that's the joy of multi-core processing... Smiley
Moderator
Moderator
Posts: 18,074
Thanks: 2,616
Fixes: 192
Registered: 06-04-2007

Re: Processor Affinity

Thought that was the case but just wanted to be sure.
Thanks Smiley
Overnight I set Handbrake to use all 6 cores at the highest priority and things zip through quite nicely.

Forum Moderator and Customer
Courage is resistance to fear, mastery of fear, not absence of fear - Mark Twain
He who feared he would not succeed sat still

matthews
Rising Star
Posts: 141
Thanks: 6
Fixes: 1
Registered: 13-08-2014

Re: Processor Affinity

If your processor has hyper-threading enabled then there is a small difference between the cores, as there are 2 logical cores per physical core. It's probably not a noticeable difference, but if you are restricting the cores that an app can use it's probably worth keeping them together and leaving 2 free at the end as then that will equate to a full physical core (1 + 1 hyper-threaded).
VileReynard
Seasoned Pro
Posts: 10,823
Thanks: 245
Fixes: 10
Registered: 01-09-2007

Re: Processor Affinity

Does Windows run on a preset 4 fixed cores or does it just take any four cores out of six concurrently?

sjptd
Grafter
Posts: 467
Registered: 01-09-2014

Re: Processor Affinity

I don't think Windows runs on only 4 cores. 
Actually difficult to draw a line and say exactly what you mean by 'Windows' here.  If you mean all the system processes such as indexing, disk handling, etc etc etc I think it quite likely it would often use as many cores as you have.
matthews
Rising Star
Posts: 141
Thanks: 6
Fixes: 1
Registered: 13-08-2014

Re: Processor Affinity

It's most likely a licencing issue (see the bottom of http://windows.microsoft.com/en-us/windows7/products/system-requirements, can't find the same restriction for Windows Cool. Reading into that I would imagine that it uses a single physical processor, meaning if you had 4 cores over 2 CPUs it would use 0 and 1 (and not use 2 and 3). Obviously it would be more efficient to use 0 and 2, but that's what they want to charge you for!
Community Veteran
Posts: 14,345
Thanks: 685
Fixes: 10
Registered: 01-08-2007

Re: Processor Affinity

I thought the actual windows core runs on just one core because having gone from a single core machine to a machine with 8 cores, there is no difference in boot time.
I'd expect it to be smoking where it boots so fast but its just as slow as the old machine. I appreciate that hard drives still work at the same speed but with 8 cores, there should still be a noticeable difference - especially when a single core machine doesn't have the HDD constantly turned on during boot.
AFAIK windows runs on one core but then does a round robin (or similar) with all other processes on all the available cores?
Looks like matthews has beat me to it with a similar suggestion..
I need a new signature... i'm bored of the old one!
VileReynard
Seasoned Pro
Posts: 10,823
Thanks: 245
Fixes: 10
Registered: 01-09-2007

Re: Processor Affinity

The reason I asked is that the Linux kernel runs on one or more cores - but not the same ones from one second to the next.
I've only get 4 cores, so it's never been worth the bother of limiting the number of cores.
Handbrake just runs each core at 99+%

sjptd
Grafter
Posts: 467
Registered: 01-09-2014

Re: Processor Affinity

I think Windows (or Unix) will use the cores more or less at random as threads are switched in and out.  Slight benefit on staying on one for the low level cache.  Slight benefit of moving around when not all cores are in use, as the cores can keep at more or less the same temperature and turbo-boost can up the speed of those currently in use.  I have no idea how significant either of those effects are.
I'm surprised 8 cores didn't improve boot time a bit, but usually boot is pretty much I/O bound so it wouldn't make all that much difference.  If you have network connections around, especially ones that are not actually available, that can slow boot down while Windows waits to try to connect.  It can also really slow down bringing up a file dialog box, even when it shouldn't need to go near the missing resource.
dragon2611
Grafter
Posts: 283
Registered: 20-10-2013

Re: Processor Affinity

I'm pretty sure that when cpu load is very low most modern OS's can actually put cores to sleep to save power.
I've noticed on my C2750 (8 core atom) that when it's not doing a lot cores 5-8 have no utilisation at all, but as soon as things start getting busy they start showing load.
matthews
Rising Star
Posts: 141
Thanks: 6
Fixes: 1
Registered: 13-08-2014

Re: Processor Affinity

If you'd like to learn some more about booting in Windows and exactly what it entails, give this link a try.
Edit:
Also here and here
Community Veteran
Posts: 14,345
Thanks: 685
Fixes: 10
Registered: 01-08-2007

Re: Processor Affinity

Quote from: dragon2611
I'm pretty sure that when cpu load is very low most modern OS's can actually put cores to sleep to save power.
I've noticed on my C2750 (8 core atom) that when it's not doing a lot cores 5-8 have no utilisation at all, but as soon as things start getting busy they start showing load.

Well I'm on Win7 pro and i've not found anything that indicates it can sleep a core. If the computer isn't doing much then the cores will of course show 0% useage - thats normal but doesn't mean they've been put to sleep. If you sit and watch them for long enough you will every now and then see a core go to 1% before going silent again.
This is my current task manager:

I don't have a great deal running at the moment but i've been putting windows to sleep every night and then waking it up the next day for over a month - which in its own right tends to confuse windows and cause it to start using more resources. I have my browser using over 1GB of ram, google earth open, firefox and a few other programs however if i did a clean reboot most of those cores would be at 0% (sorry i won't be proving that lol - too much hassle).
Quote from: sjptd
I'm surprised 8 cores didn't improve boot time a bit, but usually boot is pretty much I/O bound so it wouldn't make all that much difference.

I was surprised too and a bit miffed by it to be honest but i suppose it's just one of those things. The main core of windows is never going to be multiple threads, it will be one that controls everything else and spawns new threads for new processes etc so when you think about it logically, it couldn't really one on more than one core when booting up anyway. Well.. thats my take on it lol.
I need a new signature... i'm bored of the old one!
sjptd
Grafter
Posts: 467
Registered: 01-09-2014

Re: Processor Affinity

The main core of windows is never going to be multiple threads, it will be one that controls everything else and spawns new threads for new processes etc
If there is one controller thread it would be arranged to do almost no work itself, and so should not be a bottleneck under usual circumstances (including boot time).  Despite what you said earlier about HDD appearing to be inactive during part of boot, system SSD is generally accepted as the best way to improve boot time (Windows or Unix).
Community Veteran
Posts: 5,237
Thanks: 1,321
Fixes: 31
Registered: 16-10-2014

Re: Processor Affinity

Processor affinity is used by the scheduler of the OS to ensure that a thread launched on processor X returns to processor X after a context switch. However doing this is only of advantage when the data being used by the thread and contained in the cache remains there during the context switch. For example, if you have two threads that are reading the same data the data will be copied to their respective caches, and both process can work on it. However, if one of the threads modifies the data then the changes need to be copied to the cache on the second thread, and this can be a very expensive and slow operation in terms of CPU instructions.
There are times that when using affinity will give you a noticeable increase in performance, but this is subject to the amount of data being used by the affinity bound threads, the load on the machine, the size of the various caches (L1, 2 and 3 if you have one), and the amount of the data being used by the other threads.