A password will be e-mailed to you.

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.

Pages: [1] 2
Author Topic: Affinity Mask and Hyper threading
Zach-
Heylmun
Lockheed Martin
Posts: 46
Send Message
Post Affinity Mask and Hyper threading
on: June 25, 2012, 15:30

Just Re-Posting this where people will see it:

The affinity mask is a one byte ( 8 bit ) mask that tells our job scheduler which logical processors to schedule jobs on. If you have a 6 core processor with hyper threading, i.e. a 3960x, 3930k, etc., your processor has more cores than are covered by our bit-mask. Nevertheless, Prepar3d's default behavior seems to be to use one of the threads on each of the two extra cores. This is the desired behavior, so I see no reason to worry about it.

The reason that Prepar3d selects every other logical processor and many recommend disabling hyper threading entirely has to do with the way hyper threading works, as well as the type of tasks we thread off to background threads. Hyper threaded processors have certain select parts of their cores duplicated, which allow them to process two commands at once on a single processing core. That being said, they share the same components for accessing system resources like main memory and hard disk access. These resource access operations are very slow, and these are the primary tasks that we farm out to background threads. These resource access tasks perform very poorly when placed on both logical cores of a single hyper threaded processor core. Because the two logical cores share access to system resources, their I\O requests can interrupt one another, causing additional hard drive seeks and other expensive operations. For this reason, it does not benefit Prepar3d to use all of the cores on a hyper threaded processor, and doing so can in fact contribute to stutters.

My suggestion is to use the bit mask to map one thread to each physical core on a processor except for the primary core, which will almost always be I\O bound to begin with. I would leave hyper threading enabled at the system level because it does have benefits in general computer use and many other applications.

Zach Heylmun

PREPAR3D Software Engineer

Arismac
Professional
Posts: 166
Send Message
Post Re: Affinity Mask and Hyper threading
on: June 25, 2012, 22:54

May we have a step by step setup procedure for dummies please, Zach? AffinityMask=1344 (Binary 10101000000) is my current setting for the 3960X and HT is enabled. Should I have an Affinity Mask setting of 2730 (101010101010)? Many thanks

Cheers, Mac Web Site
Gigabyte GA-X79-UD5 | EVGA GTX580 | Intel Core i7 3960X | Corsair 16GB Kit (4x4GB) | Vertex-3 480GB SSD | VRaptor 930GB | Thermaltake 1200w PSU | Corsair H100 Cooler | Win 7 64bit | Prepar3D v1.4 | MS FSX |

janvaane
Professional
Posts: 544
Send Message
Jan Vaane
Post Re: Affinity Mask and Hyper threading
on: June 26, 2012, 06:02

Answered here http://www.prepar3d.com/forum-5/?mingleforumaction=viewtopic&t=1324.0
read from right to left
01 01 01 00 00 00 >>core 0-1-2 are not used; core 3-4-5 are used without HT
10 10 10 10 10 10 >> all core are set to hyper threading; don't use these

Jan Vaane - http://flightsimeindhoven.nl/?page_id=6715

Zach-
Heylmun
Lockheed Martin
Posts: 46
Send Message
Post Re: Affinity Mask and Hyper threading
on: June 26, 2012, 09:19

Hey Guys,
The affinity mask is only 8 bits. That means that you can only explicitly control how tasks get mapped to 8 of the 12 logical cores. Inputting values larger than 255 into the affinity mask has no effect. As I mentioned before however, the default behavior seems to be to use cores 8 and 10, so there is no real cause for concern. I believe that 84 is usually the best value for Intel 4 and 6 core chips with hyper threading. If you have very low system utilization ( meaning that you have pretty much nothing else running on your machine ), 85 may in cases perform better.

Here's how it breaks down:
84 = 0101 0100 Flip the order to get your actual processor usage: 0010 1010
Nothing on core 0 or 1, the first physical core.
One thread on each of the other 3 physical cores.

85 would be:
85 = 0101 0101 Flipped: 1010 1010
One thread per physical core.
This usually doesn't work as well, because the operating system and lots of other small tasks run on the first core.

Zach Heylmun

PREPAR3D Software Engineer

Arismac
Professional
Posts: 166
Send Message
Post Re: Affinity Mask and Hyper threading
on: June 26, 2012, 19:52

Many thanks Zach. I will set to 84 as my machine is only used for P3D.

Cheers, Mac Web Site
Gigabyte GA-X79-UD5 | EVGA GTX580 | Intel Core i7 3960X | Corsair 16GB Kit (4x4GB) | Vertex-3 480GB SSD | VRaptor 930GB | Thermaltake 1200w PSU | Corsair H100 Cooler | Win 7 64bit | Prepar3D v1.4 | MS FSX |

Zach-
Heylmun
Lockheed Martin
Posts: 46
Send Message
Post Re: Affinity Mask and Hyper threading
on: June 27, 2012, 11:00

I would test and compare the two and see which gives you the smoothest performance, but they should both work pretty well.

Zach Heylmun

PREPAR3D Software Engineer

JamesM
Beginner
Posts: 39
Send Message
JamesM
Post Re: Affinity Mask and Hyper threading
on: June 28, 2012, 17:23

Thanks Zach it's nice to have clarification on this subject from lockheed. I'm using 84 works like a charm.

DannyH73
Beginner
Posts: 25
Send Message
Post Re: Affinity Mask and Hyper threading
on: July 2, 2012, 19:35

Okay - i'm a little confused now. I have a Logitech G15 keyboard running sirreal's panel which gives me a visual indicator of what the cores of my i7-980x are doing - both physical and HT cores. When i set to affinitymask to 84 i can see core 0 and 1 now have minimal activity, core 2 move to about 100% load, and core 4 and 6 max out as well, but cores 8 and 10 just bounce around a little. When i set affinitymask to 1364 (a setting you'd assume for all physical cores except the first) i get cores 2, 4, 6, 8 and 10 all getting well used and a more fluid framerate.

If the affinitymask is only 8 bit, why would i be seeing so much better physical core usage with a setting of 1364? - and this is observation of the processors activity, not my perception of better performance. Like I said, a little confused now ....

jimcooper1
Professional
Posts: 344
Send Message
jimcooper1
Post Re: Affinity Mask and Hyper threading
on: July 3, 2012, 06:42

Danny,
I have a 6 core (12 thread) CPU and I have experimented with AfiinityMasks that go beyond 8 threads and have seen the load spread across those higher cores too.
Jim

janvaane
Professional
Posts: 544
Send Message
Jan Vaane
Post Re: Affinity Mask and Hyper threading
on: July 3, 2012, 07:53

A process affinity mask is a bit vector in which each bit represents a logical processor on which the threads of the process are allowed to run. By changing the value of the bit mask for P3D.exe you will open the doors to other cores as well for that process only. Generic P3D opens 47 processes that will run on the cores set by the affinity settings; another 200 processes (of which a number of them are called by P3D or shared by other running programs, are running in Windows and run all on cores. The reason that this is not observed is in the fact that the windows processes consume little to "none" processor time in relation to p3d.exe.

Jan Vaane - http://flightsimeindhoven.nl/?page_id=6715

Zach-
Heylmun
Lockheed Martin
Posts: 46
Send Message
Post Re: Affinity Mask and Hyper threading
on: July 3, 2012, 11:43

Hey guys,
After your comments about larger affinity masks, I checked out the use of the affinity mask internally and you are correct. The affinity mask is 32 bits, despite looking like a byte in a few places externally. The behavior remains the same, but for the 6 core processors you can definitely put in those larger values.

Zach Heylmun

PREPAR3D Software Engineer

DannyH73
Beginner
Posts: 25
Send Message
Post Re: Affinity Mask and Hyper threading
on: July 3, 2012, 15:29

Thanks for looking in to that Zach - no longer confused ;o)

Just on this matter though, the difference of taking Prepar3d off the first core and letting it run on the last 5 physical cores has been great. Weather injection from REX-essentails particularly so.

as355
New User
Posts: 8
Send Message
Post Re: Affinity Mask and Hyper threading
on: August 9, 2012, 03:45

Any idea on how we should set the affinity mask on AMD FX processors with CMT?
I'm running an 8120 which is performing really well but I'm not sure if we should be running 2 threads per module.

I have both the microsoft scheduler tweaks installed.

imcp3137
Advanced
Posts: 78
Send Message
Post Re: Affinity Mask and Hyper threading
on: August 12, 2012, 21:20

Helpful discussion, but I have an Intel 3960X, which has 6 cores, 12 threads.
What should I put in the P3D cfg file to give effect to the binary explanation you give above.
[Jobscheduler]
Affinity Mask=????

janvaane
Professional
Posts: 544
Send Message
Jan Vaane
Post Re: Affinity Mask and Hyper threading
on: August 13, 2012, 03:08

2047
whatever the Affinity value initial is, you can change that on the fly, using Task Manager on the Processes Tab and selecting right mouse Set Affinity. Since you have a 12 threads you may want to use them all except the highest numbered (11) reserved for networking.
This is how to configure the affinity value: http://janvaane.org/virtualfsx/?p=4
12 cores : #11 off >> 2047

Jan Vaane - http://flightsimeindhoven.nl/?page_id=6715

Pages: [1] 2
Mingle Forum by cartpauj
Version: 1.0.31 ; Page loaded in: 0.163 seconds.