Jump to content
Sign in to follow this  
MammyJammy

New P3D 5.3+ Affinity Mask Calculator

Recommended Posts

Trying to restrain the OS processes to a single Core or Logical Processor may be a bit frustrating, and at the very least a lot of work. For a 4 core HT Intel CPU a possible AM option could be:

[JobScheduler]
AffinityMask=254
P3DCoreAffinityMask=246
MainThreadScheduler=1
RenderThreadScheduler=2
FrameWorkerThreadScheduler=4

The 1st LP of Core 0 is for running the apps we use alongside the sim (Active Sky, LNM, etc.).  The 1st LP of Core 1 is the MainThreadScheduler, and the 2nd LP is masked off from everything.  The 1st LP of Core 2 is the RenderThreadScheduler.  The 1st LP of Core 3 is the FrameWorkerThreadScheduler.  The 2nd LP's of Core's 0, 2, and 3 are for terrain loading.  The OS will run as it always does, on all LP's.

Share this post


Link to post
On 1/27/2022 at 10:37 PM, MammyJammy said:

With a quiet hour during my workday I was able to upload another thing I've been working on for a little while:  A helpful tuning guide for squeaking out some extra system performance for Prepar3D.  At the very bottom of the Affinity Calculator is a help section, and the last item in the list has some non-affinity optimizations you may find helpful.  It includes things like power settings, Nvidia control panel settings, disk options, etc.  A lot of this is stuff I've gathered over the years here at the Avsim forums and other places and does not involve any Prepar3D.cfg tweaks beyond the affinity masking that is the main topic of this thread.

Your mileage may vary, but all of this has been helpful on the last three systems I've built for P3D.

https://izn-flightsim.s3.amazonaws.com/affinity.html

spacer.png

A very nice help and thank you for your attribution to the community. 

Especially the AM calculator should be a huge help ton those who aren't so familiar with this! 

Marcus


Regards,

Marcus P.

xaP1VAU.png

Share this post


Link to post
5 hours ago, MammyJammy said:

 

 

My advice for both of you would be the same, given you have 4 core processors with hyperthreading on:

1)  Give P3D as many cores as you can.  The newer 64-bit versions are much better at leveraging high core counts, so give P3D as much as you can.  If you mask off 1 core and 1 HT logical processor, you are giving up 25% of your compute power.  You can move the ThreadSchedulers around to give some breathing room from the OS and other stuff far more effectively w/ P3D 5.3.

2)  Only put the ThreadSchedulers on physical cores.  You want these to have as much horsepower as possible and that's not in the hyper thread of a given core.  The worst case would be running two thread schedulers on the same core/HT core.  Yikes, don't do that...You'll run out of compute on that core.

For both, I'd recommend something more like this, leveraging all cores but being specific about where the ThreadSchedulers go:

https://izn-flightsim.s3.amazonaws.com/affinity.html?cores=4&threads=8&affinity=255&coreAffinity=255&mainThread=2&renderThread=4&frameThread=6#presetAnchor

If you really want to keep a core open for your OS, go for it, but I'd give it only a single core if you can.  As per some other recommendations in this thread, I'd still leave the full AffinityMask on all cores.  Something like one of these options:

https://izn-flightsim.s3.amazonaws.com/affinity.html?cores=4&threads=8&affinity=255&coreAffinity=252&mainThread=0&renderThread=2&frameThread=4#presetAnchor

OR

https://izn-flightsim.s3.amazonaws.com/affinity.html?cores=4&threads=8&affinity=255&coreAffinity=254&mainThread=1&renderThread=3&frameThread=5#presetAnchor

Of course you will have to test what works best on your respective systems and the type of flying you do.  The free core may work better based on your add-ons, so experiment.

Hope it helps.

1) P3D uses all cores, yes, but no equally. It is bound to overuse core 0, and if that is being used by other stuff, P3D will significantly slow down. That‘s why you have to have the mainthread core exclusively used by P3D, that‘s the most important part.

Generally the problem is: While the windows job scheduler does a good job managing loads and reacting when cores are being overused, it is that: only a „reaction“. This reaction means you will have stutter for a second, when the mainthread is also being used by let‘s say ActiveSky, before the job scheduler can react. Those stutters are what we are trying to remove, and we do that, by preventing this situation at all - nothing on the mainthread but the mainthread. (Nothing means: No other P3D-processes -> that‘s what the affinity mask does & no other processes -> that‘s what we have to do manually or by Process Lasso, by restricting other apps to non-P3D cores)
Anything else is mostly cosmetic and really overcomplicates stuff for almost no gain.

Share this post


Link to post
8 hours ago, VHOJT said:

Sorry to be obtuse, do you mean:

Use LP (logical processor) 1 for leftover process (leaving LP 0 for Windows), or use LP 5,6,7 for leftover processes (these aren't specifically allocated to any P3D task)?

6700K has four cores, 8 LPs with HT on.

LPs 0 and 1 are the same physical core, as are 2 and 3, 4 and 5, 6 and 7 in your case. What you wanna make sure is, that the cores, P3D uses, are only used by P3D, and that they don‘t interfere with each other either.
If you leave LP 1 for one thing and LP 0 for another thing - you are basically doing nothing, since it‘s the same physical core. P3D needs three specific cores for itself, so you have only one left over. So let‘s say 01, 23, and 45 are for P3D, then there is 67 left for anything else.

Share this post


Link to post

Thanks for the suggestions and input, I will give those options a go.

Is the use of Process Lasso recommended, and if so, is it just a case of configuring it to put AS, RC etc onto core 0/1?

Edited by jjf

Share this post


Link to post

Hi Guys,

Im not very good with computers and the AF mask is a little to much for me.

I have a i7 11700K no O/C with 8 phyical cores and 16 logical cores with HT on,the AF mask i have in my P3Dv5 config is,

[JobScheduler]
AffinityMask=65535
P3DCoreAffinityMask=65535
MainThreadScheduler=0
RenderThreadScheduler=2
FrameWorkerThreadScheduler=4

Just asking if that is the correct settings for my CPU.

With Thanks

Gary Jones.

Share this post


Link to post
2 hours ago, Benbo said:

Hi Guys,

Im not very good with computers and the AF mask is a little to much for me.

I have a i7 11700K no O/C with 8 phyical cores and 16 logical cores with HT on,the AF mask i have in my P3Dv5 config is,

[JobScheduler]
AffinityMask=65535
P3DCoreAffinityMask=65535
MainThreadScheduler=0
RenderThreadScheduler=2
FrameWorkerThreadScheduler=4

Just asking if that is the correct settings for my CPU.

With Thanks

Gary Jones.

I have the same processor, with HT on. The following is what I have been using for about a week now and seems perfect so far:

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

This was recommended for a processor with 8 cores 16 logical from another post.

Kind regards.

  • Like 2

CPU: i7 11700K @ 5.0 Ghz | GPU: Gigabyte Aorus Master RTX 3070 | Mobo: ASUS ROG Strix Z590-F  | RAM: 32GB Corsair Vengeance RGB PRO 3200MHz | Harddrive: 3x Samsung 1Tb 970 Evo Plus M.2 SSD | Peripherals: TrackIR 5, Fulcrum One Yoke, Thrustmaster Hotas Warthog, Saitek Combat Rudder Pedals

Share this post


Link to post

Hi,thanks for that i will give it a try,thanks again.

Gary

Share this post


Link to post

Anybody using a 4790k with HT (I did a search and didn't find anything)? If so, are you using the default AM setting in P3D.cfg or other? I looked at the AM calculator linked here and am confused about what to put where.  I generally have HT off but turned it on after reading the posts here but didn't really see any difference. I don't use Process Lasso.

Many thanks!

Edited by pgde

Gigabyte x670 Aorus Elite AX MB; AMD 7800X3D CPU; Deepcool LT520 AIO Cooler; 64 Gb G.Skill Trident Z5 NEO DDR5 6000; Win11 Pro; P3D V5.4; 1 Samsung 990 2Tb NVMe SSD: 1 Crucial 4Tb MX500 SATA SSD; 1 Samsung 860 1Tb SSD; Gigabyte Aorus Extreme 1080ti 11Gb VRAM; Toshiba 43" LED TV @ 4k; Honeycomb Bravo.

 

Share this post


Link to post

Let me start by saying this seems to be a great tool to calculate an affinity mask the easy way!

But although I suspect that the answer will be: don't change what isn't broken, I will ask the question anyway:

I haven't set any affinity mask whatsoever (P3d V5.3 latest HF) and the cores on my 12700K usually hover around 60-70%. Only when loading at startup the cores are at 100%. When I then start flying most cores keep hovering around 60-70% with an occasional 80% spike.

Since the cores aren't maxed out it seems that P3D does a fine job handling the affinity mask by itself.

So I fail to see the point in tinkering with affinity masks with the last 12th gen Intel CPU but I also see that several people in this thread have done so. Is there a reason why you should need to do that? Perhaps I am missing something here?

Peter

 

Share this post


Link to post

As with all my previous CPUs, there is a consistent performance improvement (in my case) by having SMT on in the BIOS (SMT = HT with AMD CPUs) and only using the physical cores of the CPU for the processes. On my Legion 5 PRO laptop with an 8-core, 16-thread AMD Ryzen 7 5800H and an RTX3070 (165W model) it's easy to fly the FSL Airbus out of FSDT KLAX at 30fps with these:

[JobScheduler]
AffinityMask=21845
P3DCoreAffinityMask=21845
MainThreadScheduler=7
RenderThreadScheduler=6
FrameWorkerThreadScheduler=5

This is one of my worst case scenarios, i never had good performance out of FSDT KLAX, while YSSY for example with all terrain addons from ORBX has better performance.

Anyway, just my 0.02c and very happy with 5.3HF2, it's a real performer.


CASE: Custom ALU 5.3L CPU: AMD R5 7600X RAM: 32GB DDR5 5600 GPU: nVidia RTX 4060 · SSDs: Samsung 990 PRO 2TB M.2 PCIe · PNY XLR8 CS3040 2TB M.2 PCIe · VIDEO: LG-32GK650F QHD 32" 144Hz FREE/G-SYNC · MISC: Thrustmaster TCA Airbus Joystick + Throttle Quadrant · MSFS DX11 · Windows 11

Share this post


Link to post

@MammyJammy, I've been using your spreadsheet / calculator to determine the appropriate values for my 6 core / 12 VP i7-8086K and I'm confused. I've recently turned hyperthreading back on.

I enter 6 and 12 into the front page and continue to the main section where I have a choice of options. The advice from @SteveW is to keep the first core free for the OS. So I choose that option - First Core Free.

But on the resultant colour boxes VPs 0 and 1 are still shown in light blue. I would have expected them to be grey - (not used for P3D).

The calculated AffinityMask value is 4095 and the P3DCoreAffinityMask is 4092.

That suggests that ALL cores are being assigned to P3D but why when I chose First Core Free?

When I start P3D and it's stabilised I open Task Manager - Details tab and right-click the Prepar3d.exe and choose Set Affinity.

All 12 VPs are ticked and back in the Performance tab cores 0 and 1 are being used. Why when I chose "First Core Free"?

If I calculate the AffinityMask manually the sum of 4+8+16+32+64+128+256+1024+2048 is 4092. That means cores 0 and 1 should have little usage but they're just as busy as the remaining cores.

I'm sure you're right and I've misunderstood something but quite what is baffling me.

  • Like 1

Ray (Cheshire, England).
System: P3D v5.3HF2, Intel i9-13900K, MSI 4090 GAMING X TRIO 24G, Crucial T700 4Tb M.2 SSD, Asus ROG Maximus Z790 Hero, 32Gb Corsair Vengeance DDR5 6000Mhz RAM, Win 11 Pro 64-bit, BenQ PD3200U 32” UHD monitor, Fulcrum One yoke.
Cheadle Hulme Weather

Share this post


Link to post

Ray,

6 core / 12 LP I recommend to write out the logical processor map:

HT Enabled 16 core
05,04,03,02,01,00=core number
11,11,11,01,01,01=AffinityMask = 4053
11,11,11,01,01,01=P3DCoreAffinityMask = 4053
00,00,00,00,00,01=MainThreadScheduler = 0 = core 0 LP0
00,00,00,00,01,00=RenderThreadScheduler = 1 = core 1 LP2
00,00,00,01,00,00=FrameWorkerThreadScheduler = 2 = core 2 LP4

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

if you copy/paste "11,11,11,01,01,01" into the BIN field of Windows Calculator (programmer mode) you will see 4053 in the DEC field.

I have been checking this on my test harness and works great on 60Hz monitor with Nvidia Control Panel, Manage 3D Settings, Program Settings, Prepar3D.exe profile, then set “Vertical sync” to Adaptive (half refresh rate) gives a VSync of 30Hz. In P3D “Display Settings” choose Unlocked on the fps slider control, and set VSync=On. Smooth as glass with very small time delta between frames. On my system these settings with Vsync=Off the frame rate may look limited to 30 fps but there are times when the fps shoots up and down quite a bit, with Vsync=On this reduces that behaviour quite a bit for a smoother frame to frame time overall. This also works well by setting the monitor to 30Hz refresh rather than use NCP  Adaptive (half refresh rate) and again setting VSync=On and Unlocked on the fps slider control in P3D Display Settings..

The default P3D affinity setting for HT enabled is not so good as it will allow scenery gathering to share the three important cores. No need to avoid core zero for the operating system including using core zero for two scenery gathering LPs as shown next:

If you want to try avoiding core zero you can try:

HT Enabled 16 core
05,04,03,02,01,00=core number
11,11,01,01,01,11=AffinityMask = 3927
11,11,01,01,01,11=P3DCoreAffinityMask = 3927
00,00,00,00,01,00=MainThreadScheduler = 2 = core 1 LP2
00,00,00,01,00,00=RenderThreadScheduler = 3 = core 2 LP4
00,00,01,00,00,00=FrameWorkerThreadScheduler = 4 = core 2 LP6

[JobScheduler]
AffinityMask=3927
P3DCoreAffinityMask=3927
MainThreadScheduler=2
RenderThreadScheduler=3
FrameWorkerThreadScheduler=4

Works just as well, no discernable difference in the test.
 

  • Upvote 1

Steve Waite: Engineer at codelegend.com

Share this post


Link to post

Hi Steve, appreciate the reply. I notice on the first three cores (6 VPs) you’re using only one VP on each. Is that to allow sharing with the OS?

Your “avoiding core 0” example appears to have cores 0 and 1 both on. Confusing.

The references to 16 cores should be 12 of course. 😉

I’m running my monitor at 30Hz. Still undecided if HT On is better than HT Off. Is there any real improvement with one over the other with 6 cores?

  • Like 1

Ray (Cheshire, England).
System: P3D v5.3HF2, Intel i9-13900K, MSI 4090 GAMING X TRIO 24G, Crucial T700 4Tb M.2 SSD, Asus ROG Maximus Z790 Hero, 32Gb Corsair Vengeance DDR5 6000Mhz RAM, Win 11 Pro 64-bit, BenQ PD3200U 32” UHD monitor, Fulcrum One yoke.
Cheadle Hulme Weather

Share this post


Link to post
24 minutes ago, Ray Proudfoot said:

Is that to allow sharing with the OS?

No, it’s to ensure that the 3 main threads don’t conflict with each other or a scenery gathering thread.

25 minutes ago, Ray Proudfoot said:

Your “avoiding core 0” example appears to have cores 0 and 1 both on. Confusing.

Steve means leaving the entire core free for the OS is a waste of resources because the OS won’t need that core all the time.  Placing scenery gathering threads there maximises the loading capacity of the sim, whilst the main threads are protected on cores 1,2 and 3.

27 minutes ago, Ray Proudfoot said:

Is there any real improvement with one over the other with 6 cores?

more consistent timeframes mostly, and/or less visible paging in of scenery because it can load more efficiently.

  • Like 2

Kevin Firth - i9 10850K @5.2; Asus Maximus XII Hero; 32Gb Cas16 3600 DDR4; RTX3090; AutoFPS; FG mod

Beta tester for: UK2000; JustFlight; VoxATC; FSReborn; //42

xaP1VAU.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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...