Mysterious increased performance via task manager affinity setting

Any issues, problems or troubleshooting topics related to computer hardware and the Prepar3D client application
Dex
Posts: 3
Joined: Wed Mar 19, 2014 1:10 am

Post by Dex »

I have a somewhat unusual question/observation regarding the affinity mask setting on the Prepar3d process. After reading up a bit on using the AffinityMask setting in Prepar3d.cfg I've been playing around with different values trying to find out what works best. Ultimately I've decided to go with a value of 252, which tells P3D to use all physical and logical cores except for the first two which would be set aside for the OS and other applications. The default value for my processor that P3D selects is apparently 84, which excludes the logical (HT) cores.



However, that's not what this post is about. To facilitate my testing of different values I had been changing the affinity mask dynamically via the Windows Task Manager (right click on P3D process->Set Affinity). I noticed that if I apply the affinity mask while P3D is running, textures and autogen load MUCH faster, even while slewing around at high speeds. That's without even changing the value--just opening the affinity mask selection and clicking OK is enough to put P3D into overdrive. I'm having trouble understanding why that would be the case--I can see all the assigned CPUs being exercised before and after I go through these motions, but something seems to be behaving differently after I click that OK button. Hopefully I explained this clearly enough, and would be interested in hearing other's findings. My specs are below:



PC: MSI GT70

CPU: Intel Core i7-3630QM @ 2.40 GHz

VGA: Nvidia GeForce GTX 680M

RAM: DDRIII 16GB
Nullack
Posts: 285
Joined: Thu Jul 11, 2013 3:33 am

Post by Nullack »

I dont see how setting it via TM, a third party app or within P3D is any different. If CPU affinity is set, its set.
hermes82
Posts: 395
Joined: Mon Jun 25, 2012 3:05 pm

Post by hermes82 »

i've noticed the same thing setting it manually since v2.1, don't know why but it does make a difference
User avatar
dafyddp3d
Posts: 209
Joined: Tue Mar 13, 2012 9:23 pm
Location: Birmingham UK

Post by dafyddp3d »

The only comment I would make on setting the AM externally is that if P3D has set up it's threading regime on the assumption that it is using a certain cpu configuration, which is set WITHIN the application, then subsequently altering the process affinity externally to a value that does not match the value P3D assumes is in use could have strange results. Perhaps LM could comment on this.



The organisation of threads in P3D certainly seems to give weird results



I also decided to play around with the AM, and find that with Intel HT (Hyperthreading) Technology enabled in the BIOS, a value of 85 (01010101) gives me the best result overall, and the sim runs smoothly, no blurred textures. The value of 85 makes use of all four physical cores, with one thread (or logical cpu if you like), running on each.

However, if I don't bother to set the AM in the cfg file, P3D seems to default to the value 84, which leaves Physical core 0 free for system use. This setting, for me at least, results in slow texture loading and blurred textures.



So, on the strength of the above observations, I decided to disable Intel HT via the BIOS, and set a value of 15 for the AM in the cfg file. This produced even better results, with my framerate (set at 40fps) increasing from around 30, to 35 to 40. This is now my preferred option.



BUT! .....When out of curiosity, I re-enabled HT via the bios, the PC booted normally into Windows, and leaving the AM setting out of the CFG, P3D started normally, the scenario screen was OK, and the sim went through the texture loading phase as normal. However when the final screen (Windowed 1920 x 1050) was produced, rendering of the window froze, and after around 10 secs P3D closed without warning.

Altering the AM in the cfg file and re-starting P3D had no effect on this behaviour.

If I disabled HT in the BIOS, (AM re-set to 15), all was well again. Re-enabling HT resulted in the app freezing and closing.



I finally got out of the (self induced!) problem, by removing the AM lines in the cfg, and simultaneously deleting the shader cache, before starting P3D. After that the app behaved more or less normally. Go figure!



So the enabling / disabling of both Intel HT, and the affinity mask setting could cause a few headaches, hence my post, might help someone who gets confused, like me!



Right now, HT is disabled, AM is set to 15 in the cfg, Task Manager shows all four Cores hammering away, and the Simulator is running smoothly!



Nice job LM!
Dave Nash

P3D v5.3.17.28160 on Win 10 64 bit (21H2.19044.1682)
3 x 4k Monitors driven by 3 x GTX1080Ti
Mobo MSI X99A SLI Plus, with Core i7-5930K @ 4.2GHz, 32GB Mem (3000MHz), Corsair M500 SSDs
FSUIPC, PMDG 747, 777, VRS FA18
hermes82
Posts: 395
Joined: Mon Jun 25, 2012 3:05 pm

Post by hermes82 »

I tried enabling HT but without AM setting in cfg and had issues so switched off HT then carried on as before, i'd noticed previously that the scenery was blurred on the default AM setting but all clears up enabling core 0 again in TM, i'm using an i7 2700k 3.5-3.8 ghz not overclocked and asus gtx650 ti also not clocked and have good framerates although setting fps to unlimited caused texture load problems and stuttering so set to 40fps and getting a healthy 28-30 using the iris f16 at 400 kts very low level and crystal scenery, have a new wd velociraptor to install yet so should increase texture load times

Nullack
Posts: 285
Joined: Thu Jul 11, 2013 3:33 am

Post by Nullack »

Easy way to test this. Set AM via cfg. Look at the process affinity the kernel is running. Exit, delete AM cfg value, re-run p3d set AM via TM. Relook at process affinity the kernel is running. Notice no difference to the kernel affinity policy for the p3d process :)



People are probably stuffing up the cfg file edit for a custom AM value by saving it accidentally in notepad as prepar3d.cfg.txt as thats what notepad will default too
Paul K
Posts: 42
Joined: Sat Aug 11, 2012 12:17 pm

Post by Paul K »

Dex, I've tried your T.M. affinity mask procedure and I've noticed a considerable improvement in loading times. For example, previously, when selecting the outside view of an aircraft for the first time, first there would be nothing to see, then the internal model would appear, then the external, followed by the external textures. The process could take anything up to 5 or 6 seconds. However, since setting the affinity mask using T.M. I find the external model appears in its entirety almost instantaneously. So clearly something has improved.



What is puzzling me is why wasn't I getting this before ? In my AppData\Roaming\Lockheed Martin\Prepar3D v2\Prepar3D.CFG I have the line:



[JOBSCHEDULER]

AffinityMask=84



I am using a Core i7 960 @ 3.20 Ghz and I've checked the BIOS to ensure hyperthreading is enabled. I had assumed thats all I needed to do. I wonder if AffinityMask=84 is the correct value of my processor ...?



Anyway, marked improvement in loading times by setting affinity mask in T.M.
snake2008
Posts: 56
Joined: Mon Mar 24, 2014 1:40 am

Post by snake2008 »

Got to agree with you here, I change prepared3d while in the cockpit to run all cores and set priority in task manager to high and even with my little 560ti performance is smooth rarely dropping frames at smaller airports with less demanding aircraft.
Dex
Posts: 3
Joined: Wed Mar 19, 2014 1:10 am

Post by Dex »



Quote:
Quote from Nullack on April 28, 2014, 01:36

Easy way to test this. Set AM via cfg. Look at the process affinity the kernel is running. Exit, delete AM cfg value, re-run p3d set AM via TM. Relook at process affinity the kernel is running. Notice no difference to the kernel affinity policy for the p3d process :)



Your skepticism is entirely understandable but actually that's exactly what I did ;). That is how I determined P3D's default value of 84 for my CPU. After changing the value to 252 in the config I did see the change reflected in the TM, and as I mentioned in my original post I could see all the active cores being worked as expected. The threads must be getting swapped around somehow after clicking OK (unfortunately that's the extent of my technical insight :P ).



In any case, I still haven't decided whether to stick with my change to 252 or just leave it at the P3D default since my testing was obviously skewed by the TM. Plus I fear I'm too lazy to set the affinity manually every time I launch the sim...
User avatar
pmb
Posts: 351
Joined: Fri Jan 06, 2012 1:45 am
Location: Jena, Germany
Contact:

Post by pmb »

If you are just too lazy to use PM you can use a tool, like Easytoolz



http://home.arcor.de/jasonvoorhees2k/in ... toolz.html



(let Google translate the text, it's really easy). There are other tools doing the magic, but I use this one. This lets you set process priority, too.



Kind regards, Michael
Prepar3d4+5 Pro // Intel i7-6700K 4.0 GHz / Asus MAXIMUS VIII RANGER / Kingston 32 GB DDR4 / Samsung2 SSD 500 GB + SSD 1 TB + WD HD 6 TB / EVGA GTX 1080 Ti 11 GB / LG 34UM95 3440 x 1440 / HP Reverb / Win 10/64
Nullack
Posts: 285
Joined: Thu Jul 11, 2013 3:33 am

Post by Nullack »



Quote:
Quote from Dex on April 29, 2014, 17:44

Quote:
Quote from Nullack on April 28, 2014, 01:36

Easy way to test this. Set AM via cfg. Look at the process affinity the kernel is running. Exit, delete AM cfg value, re-run p3d set AM via TM. Relook at process affinity the kernel is running. Notice no difference to the kernel affinity policy for the p3d process :)



Your skepticism is entirely understandable but actually that's exactly what I did ;). That is how I determined P3D's default value of 84 for my CPU. After changing the value to 252 in the config I did see the change reflected in the TM, and as I mentioned in my original post I could see all the active cores being worked as expected. The threads must be getting swapped around somehow after clicking OK (unfortunately that's the extent of my technical insight :P ).



In any case, I still haven't decided whether to stick with my change to 252 or just leave it at the P3D default since my testing was obviously skewed by the TM. Plus I fear I'm too lazy to set the affinity manually every time I launch the sim...



OK mate I believe you, but would you mind quickly taking some screenshots showing this? Reason is I cant replicate it. Are you sure in both cases you didnt allow notepad to ammend .txt to the file which it does by default making a prepar3d.cfg.txt which wont work



So I know what OS and service pack level are you on please?
Dex
Posts: 3
Joined: Wed Mar 19, 2014 1:10 am

Post by Dex »

Screenshots probably don't do justice to this as well as a video probably would, but I gave it a shot anyway. I broke this experiment into two parts: first is the control sample where I set the value of 252 in the Prepar3d.cfg and didn't touch anything in TM, and for the second part repeating the experiment after clicking the OK button in TM.



First, this is just using the value of 252 defined in Prepar3d.cfg, starting off above KATL:





This is after slewing towards Stone Mountain at a constant speed of 820 knots:





For the second half of the experiment I simply clicked the OK button on the Set Affinity window in TM (I didn't re-check any of the cores). Here are the respective start and end screenshots:







As you can see, the difference in scenery loading is quite dramatic even though the CPU charts aren't very different. To answer the other questions, I'm on Windows 8.1 and I haven't mucked about with Notepad in quite a while (I use the much less annoying Notepad++).



@pmb Thanks for the link, I'll check it out to see if it serves my needs.

Nullack
Posts: 285
Joined: Thu Jul 11, 2013 3:33 am

Post by Nullack »

Dex thanks for sharing that. As you say, its very hard to see the difference your describing without a video. Blurries still occur regardless of AM values, its just that different AM values change the amount of time blurries dont resolve them by because allowing more CPU resources to process the background job means more background jobs being done in the same time period.



However, you can see in both of those screenies that from the OS kernels perspective, the affinity mask is the same. The setting is identical in both cases. This is what I meant when I said, if its set, its set. I'm not anywhere close to being convinced there is any difference at the application level but I'll do some more testing to see if I can reproduce one.
tra757
Posts: 53
Joined: Tue Jul 31, 2012 3:36 am

Post by tra757 »

I have affinity set in the p3d.cfg and I have them all enabled so when I try to change this in TM I just CTD. I haven't tried it by lowering the settings in cfg and bumping it in TM. Not sure it would do any good as my GTX 770 can't keep up with my X5675. When I lower the graphics settings in P3D my CPU usage goes up and so does frame rate. When I max out the graphics settings, my CPU utilization drops to a steady 40% and frame rate drops to around 12 on the ground and 4-6 up in the air with lots of clouds. Kinda wish now I had gotten a GTX 780. Oh well, I have found a reasonable middle ground in the settings for incredible scenery and flyable frame rate.

Andras
Posts: 36
Joined: Mon Feb 07, 2011 4:15 pm

Post by Andras »

Just my humble two cents on this.

I've experimented a lot with different AM settings in 2.1 and found that with my 4770k CPU and GF780 got the best result if I left the second virtual core and the last virtual core disabled (Am 125) if HT was on. Less blurries, faster scenery (autogen) and texture loading.

For 2.2 the entire scenario has changed. AM 125 is definitely NOT the best solution anymore and as many say here, using ALL (255) cores gives the best result. But this best result is a bit misguiding as texture loading is definitely SLOWER in 2.2 compared to any 2.1 variation of AM and other relevant settings.

Thus I came to the conclusion that the LM software guys trying to find the best solution throughout these versions, but they probably do not yet know where to go. As 2.2. defaults to the AM setting leaving the first core (or two virtual ones in case of HT enabled) probably they found this as the best for their test purposes. But I'm not at all sure if they used dense 3rd party sceneries or other heavy stuff for testing, hence the difference.

I'm almost convinced that the programmers are still experimenting and I'm not certain they do that absolutely consciously regarding the AM part.



My experiments clearly showed however that with HT ON the performance was ALWAYS better than HT off.

It's true that P3D is not yet cxapable of making use of HT but the OS does and this may result in a better performance while HT is enabled.
Locked