Jump to content
Sign in to follow this  
joepoway

Optimizing Affinity Mask Settings for P3D v5.3 and Later

Recommended Posts

Hi Ray      You had requested me to re-post this topic for use in the "Tips, Tricks and How To's" section of the forum.

___________________________________________________________________________________________________

 

The following is a summary of a post I recently made regarding the new Affinity Mask (AM) options within the P3Dv5.3 configuration file as an attempt to explain what the AM is doing. The P3D configuration file is located:

 Users > xxx > AppData > Roaming > Lockheed Martin > Prepar3D v5 > Prepar3D.cfg

If you are not familiar with making edits to this file with something like Notepad++ I suggest you proceed with caution and make a backup of the file before proceeding. If something goes wrong you can always delete the file, when P3D is launched it will generate a new configuration file. However, preferred settings within the various options pages will have to be re-established that’s why a copy reinserted would be more advantageous if necessary.

Before I start the following link will lead to a very useful tool developed by a fellow forum member @mammyjammy This tool will enable you to make various choices for any processor and provide the AM values to insert in the P3D config file. This summary does not go into detail in the use of the calculator, but the author has given excellent instructions on its use.

P3Dv5.3 Affinity Mask Calculator

I also want to acknowledge Steve Waite @SteveW  , a long-time key contributor to this forum, for providing great insights and valuable testing helping me to understand this complicated and sometimes confusing AM topic.

Note when P3Dv5.3 was installed or upgraded on your PC a default AM was generated and exists in your config file at the top of the file already. Many people think they are not running an AM in P3Dv5.3 but in fact a default one exists. To be clear you do not have to change the default it will work as is. However, we have found it useful to modify the settings particularly if you are running a processor with Hyperthreading (HT) enabled as the P3D default AM settings don’t fully optimize the HT feature yet. Additionally, processors with more than 4 cores can benefit more because of the greater number of options.

When assigning processor core AM settings, I recommend using the same core settings for "AffinityMask" and "P3DCoreAffinityMask" and not setting the "P3DCoreAffinityMask" as a subset of the “AffinityMask”. Different opinions can be found in the forum but my opinion is to set them the same, @SteveW has main posts on this subject if you want to research it.

Also, there is discussion about leaving the first core free from P3D use so the Windows Operating System can use it to assign things, I have found no real benefit while testing both Windows 10 and recently Windows 11. Additionally, if you don’t have an abundance of cores, you may actually be hindering P3D performance. Again, I’m not saying you shouldn’t explore this I’m saying I found it to not be valuable on my system which can be seen in my signature at the bottom of the post.

Assuming you have used the AM Calculator or another tool and have decided on the core assignments you want there will be 5 lines of code that need to be looked at. The following is a recommended example for a 6 core processor with HT enabled:

[JobScheduler]
AffinityMask=4053
P3DCoreAffinityMask=4053
MainThreadScheduler=0
RenderThreadScheduler=1
FrameWorkerThreadScheduler=2

For those of who like binary notation it would look something like this from right to left:

11,11,11,01,01,01 = AffinityMask=4053
11,11,11,01,01,01 = P3DCoreAffinityMask=4053
00,00,00,00,00,01 = MainThreadScheduler=0
00,00,00,00,01,00 = RenderThreadScheduler=1
00,00,00,01,00,00 = FrameWorkerThreadScheduler=2

In simple terms (I hope) from right to left in the above example think of the logical processors as P1, P2, P3, P4 and so on to P12 for this 6 core with HT example 

MainThreadScheduler = 0  puts the MainThread on P1 which is on the first of 6 cores

P3D is told with AM=4053 not to use P2 (HT of first core) therefore no scenery rendering etc. is put on the same shared core as MainThread

RenderThreadScheduler = 1 puts the RenderThread on P3 which is on the second of the 6 cores

P3D is told with AM=4053 not to use P4 (HT of second core) therefore no scenery rendering etc. is put on the same shared core as RenderThread

FrameWorkerThreadScheduler = 2  puts the FrameWorkerThread on P5 which is on the third of 6 cores

P3D is told with AM=4053 not to use P6 (HT of third core) therefore no scenery rendering etc. is put on the same shared core as FrameWorker

By doing this you are directing P3D where the main threads should be run and run on separate cores (new feature with v5.3) and keeping any other P3D activities or programs launched by P3D from using the "sister HT's" (in my terms P2, P4, and P6 with the AffinityMask and P3DCoreAffinityMask = 4053 in this example) of those three primary thread cores in use.

Additionally, I recommend using a utility to coral (keep off) other high use add-ons off the first three cores including the "sister HT's". This prevents any sharing of the primary P3D threads with other apps. That would mean nothing else on P1, P2, P3, P4, P5, and P6 which is my "plain English" reference it's really C0, C1, C2, C3, C4 and C5 in things like Process Lasso if that makes sense.

The following is a suggested example for an 8 core processor with HT enabled like my current i9-990ks:

[JobScheduler]
AffinityMask=65493
P3DCoreAffinityMask=65493
MainThreadScheduler=0
RenderThreadScheduler=1
FrameWorkerThreadScheduler=2

All the same logic as above applies this just utilizes more cores but assignments for the 3 primary P3D threads are the same first 3 cores. The AM=65493 prevents the same 3 “Sister HT” cores from being shared with the P3D primary threads.

It’s important to realize when hyperthreading is used the number of cores does not physically double. Hyperthreading shares each physical core creating a virtual core so to speak. You want to assure the assigned cores for the 3 P3D primary threads are not shared by other P3D tasks or heavy hitting add-ons. If the loading of any of those cores reaches 100% with the additive combination of say P1 and P2 (C0 and C1) in my above example stutters may arise.

Additionally, regarding HT on or off for use with P3D there are dozens of opinions, mine is if you overclock and it's stable and you don't have heat issues, I would use HT but as stated above keep things off the "HT portions" of the first three cores assigned for the three main threads of P3D. 

As mentioned above it is also beneficial but not essential to assign AM to heavy hitting add-ons that are still free to use any of the cores on your processor. I use Process Lasso to keep those apps off the assigned cores for the 3 P3D primary threads. When all the add-ons are launched with P3D running every app can be seen on the Process Lasso process page and each app can have a custom affinity mask (core assignment) assigned. If you use Process Lasso, be sure to use the “Affinity Always” assignment so it’s permanent and not a onetime assignment.

The following are a few Process Lasso discussions on the forum but there are many other tools available.   

Process Lasso Forum Topic

Continued Process Lasso Forum Topic

I hope this helps. The complexity of understanding modern processors, all the terms and actual behaviors can be very confusing, I only hope I haven't added to the confusion.

Joe

 

 

  • Like 9

Joe (Southern California)

SystemI9-9900KS @5.1Ghz/ Corsair H115i / Gigabyte A-390 Master / EVGA RTX 2080 Ti FTW3 Hybrid w 11Gb / Trident 32Gb DDR4-3200 C14 / Evo 970 2Tb M.2 / Samsung 40inch TV 40ku6300 4K w/ Native 30 hz capability  / Corsair AX850 PS / VKB Gunfighter Pro / Virpil MongoosT-50 Throttle / MFG Crosswind Pedals /   LINDA, VoiceAttack, ChasePlane, AIG AI, MCE, FFTF, Pilot2ATC, HP Reverb G2

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...