Jump to content

Recommended Posts

It calls SetProcessAffinityMask() with the value from the config and tells the kernel what cores it wants to be scheduled on. What do you think it's doing? Do you think it's calling SetThreadAffinityMask()?

That (SetProcessAffinityMask) simply causes the jobsheduler to move the app onto the unmasked cores and won't work as you intended. Nuff said here don't you think?

 

So if you start FSX with AM=0 and go into task manager and uncheck some cores, that's the API you mention in action. It doesn't take long to see that the outcome to doing that is completely different to what FSX does with an AM value.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

 

 


That (SetProcessAffinityMask) simply causes the jobsheduler to move the app onto the unmasked cores and won't work as you intended.

 

I read the document differently:

 

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.

 

But this is all a distraction. Can you provide any sort of citation for the claim that FSX:SE and P3D schedule their threads differently? I am genuinely curious.


Luke Kolin

I make simFDR, the most advanced flight data recorder for FSX, Prepar3D and X-Plane.

Share this post


Link to post
Share on other sites

I read the document differently:

 

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.

 

But this is all a distraction. Can you provide any sort of citation for the claim that FSX:SE and P3D schedule their threads differently? I am genuinely curious.

Why don't you write some code and see what these things do? FSX, FSX:SE and P3D all work slightly differently and as I said it's a commercial asset understanding what goes on under the hood there.

 

Here's another fly in your ointment; start FSX with an AM and when it's running go to task manager and see that it still appears to have an AM=0 as all the cores are checked. Do the same with P3D and you can see the masked cores are unchecked. So quite obviously they don't work the same.

 

I read the document differently:

 

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.

No I don't think so, you got it right in one. That's what I am saying when I say "causes the jobsheduler to move the app onto the unmasked cores" since that's what the AM represents, masked cores are not used so anything already there moves onto the unmasked (available) cores.

 

Once FSX has completed starting up with a specified AM value the jobsheduler is finally furnished with the AM=0 so that the jobsheduler is free to start subsequent threads anywhere on the CPU. P3D leaves the AM in place after it has started and so subsequent threads can only start on the unmasked cores.

 

It's best to realise that FSX, FSX:SE, FlightSchool and P3D all work differently in this regard and this information can be obtained simply with the use of Task Manager in an afternoon.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

Here's another fly in your ointment; start FSX with an AM and when it's running go to task manager and see that it still appears to have an AM=0 as all the cores are checked. Do the same with P3D and you can see the masked cores are unchecked. So quite obviously they don't work the same.

 

Thank you for the suggestion and pointing out the difference. I did actually write some code (with the disclaimer that it's managed, but I expect that the System.Diagnostics namespace is calling the API functions behind the scenes). If I set the process affinity, I see that reflected in Task Manager. If iterate through all of the current processes' threads and set their affinity, that isn't reflected in Task Manager.

 

 

 

No I don't think so, you got it right in one. That's what I am saying when I say "causes the jobsheduler to move the app onto the unmasked cores" since that's what the AM represents, masked cores are not used so anything already there moves onto the unmasked (available) cores.

 

I think you have it backwards. As the documentation states, the mask controls what processors are allowed to execute the process/thread. If I set a mask of 5, I am allowed to run on cores 0 and 2, and no others.

 

 

 

Once FSX has completed starting up with a specified AM value the jobsheduler is finally furnished with the AM=0 so that the jobsheduler is free to start subsequent threads anywhere on the CPU. P3D leaves the AM in place after it has started and so subsequent threads can only start on the unmasked cores.

 

From my example, what P3D is doing is consistent with it setting the affinity mask for the entire process, whereas FSX does not appear to be using this mechanism. It's definitely obeying the affinity mask, so it may be that the individual threads are getting the mask set, rather than the process.

 

What I'm not seeing is that there's any additional scheduling of threads beyond telling the kernel "execute on these particular processors". Again, I'm curious to see why you feel differently. I recognize it's closed-source and not something either of us have seen, but you seem to feel strongly that FSX:SE understands logical and physical cores differently (and better) than P3D. I don't see any evidence of that.

 

Cheers!


Luke Kolin

I make simFDR, the most advanced flight data recorder for FSX, Prepar3D and X-Plane.

Share this post


Link to post
Share on other sites

You are making mistakes of mis-reading there again Luke. By *Un-Masked* look at your AM=5=0101 and so from the right to left core zero and core 2 are used because they are unmasked, core 1 and 3 are *Masked* and not used... no?

 

So you admit you see a totally different situation between FSX and P3D. Enough said about that then. Getting into conversation about actually programming this I'm not entering into.

 

Again, I'm curious to see why you feel differently. I recognize it's closed-source and not something either of us have seen, but you seem to feel strongly that FSX:SE understands logical and physical cores differently (and better) than P3D.

Here you are making statements for me which I've not claimed that somehow FSX is better than P3D in this respect. That's a leap of understanding you made. P3D is a professional app and that it offers us control of that aspect.

 

You seem to be talking about individual threads. There are more than 50 threads making up four "jobs" the simulator makes use of available *unmasked* cores as it sees fit. If you look at the documentation when these simulators split into four parts (with four logical processors unmasked) the main rendering stage is leanest. In other words if we allocate less than four cores the sim will group these jobs together. If we allocate more than four cores the sim splits the background tasks over those.

 

I hope this conversation has proved enlightening for all.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

The Affinity mask documentation is clear. The threads run on the masked processors.

 

Take your own advice please; write some code. Set your process affinity to 64 and do an infinite loop. You'll notice CPU utilization on core #7 spikes. Adjust affinity mask to match your core count. ;)

 

 


Here you are making statements for me which I've not claimed that somehow FSX is better than P3D in this respect. That's a leap of understanding you made.

 

Please go back and read post #7 in this thread. You might be familiar with the author. ;) I'm enclosing the relevant section below:

 

FSX:SE works out what to do with HT enabled but P3D will utilise each logical processor as if it were a real core

 

I'm just curious as to the basis for this claim. Through our investigations (thanks for the suggestion) it looks like P3D is setting the processor affinity process-wide, and it appears that FSX is doing so per-thread. Beyond that, they're leaving the ultimate scheduling up to the kernel. I don't see anything to suggest that P3D or FSX care about logical/physical cores.

 

You obviously feel differently. What should I look for as evidence that FSX is determining core types?


Luke Kolin

I make simFDR, the most advanced flight data recorder for FSX, Prepar3D and X-Plane.

Share this post


Link to post
Share on other sites

Luke admit it you didn't know the difference between FSX and P3D. Also when I use an AM=64‬

...when I use an AM=64=01000000 there's only activity on core #6. The mask having only one one - the unmasked core.

 

As I already said the jobscheduler takes responsibility for where threads start. I think you found out a ton of know-how here.

 

(sorry for the oddness of the post; internet went down in my neck of the woods for a few minutes)

 

...I think you are mis-interpreting when I say unmasked i'm referring to those cores that available in the mask - I'm not suggesting using no mask. Perhaps that's the difficulty you are having?

 

...(still having issuers this end with internet sorry.)

 

What is a mask?

 

You put on a mask and I cannot see your face.

 

 

The Affinity Mask is used to Disable (or mask) cores!

 

The least significant bit on the right is representing core zero.

 

So with 8 LPs and an AM=64 we have a Mask of 01000000, core zero on the right shows it is masked with a zero, right up to core 6 which is UNMASKED with the One (1). I hope you got it now.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

 

 


...when I use an AM=64=01000000 there's only activity on core #6. The mask having only one one - the unmasked core.

 

Now I understand why we were talking past each other. You mask to zero, I mask to one. We're saying the same thing.

 

 

 

Luke admit it you didn't know the difference between FSX and P3D

 

I'm happy to admit I didn't know the difference between how FSX and P3D set their processor affinity. I still don't know for sure today, but it looks like FSX sets it per-thread, and P3D does it at the process level. That still doesn't say anything regarding FSX seeing logical cores differently than P3D. I really wish you'd explain why you said that rather than trying to attack me. My ignorance of a subject doesn't prove your claim.


Luke Kolin

I make simFDR, the most advanced flight data recorder for FSX, Prepar3D and X-Plane.

Share this post


Link to post
Share on other sites

Well, to be honest I felt your posts were designed to shave credibility off of mine Luke. I'm stating the differences clearly but you'll have to study the thing yourself or work on a project with me to get more than that.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

Well, to be honest I felt your posts were designed to shave credibility off of mine Luke. I'm stating the differences clearly but you'll have to study the thing yourself or work on a project with me to get more than that.

 

Why are you being so cryptic?

 

You've stated that FSX and P3D handle their affinity via different API calls. I agree there. I don't see how handling it differently through API necessarily translates to a completely different scheduling mechanism.


Luke Kolin

I make simFDR, the most advanced flight data recorder for FSX, Prepar3D and X-Plane.

Share this post


Link to post
Share on other sites

Why are you being so cryptic?

 

You've stated that FSX and P3D handle their affinity via different API calls. I agree there. I don't see how handling it differently through API necessarily translates to a completely different scheduling mechanism.

No I have not. I've not stated they use "different API calls" anywhere, and I've not eluded to any differences in scheduling mechanisms either. I've given you the facts they are different and I've shown you what to look for. Go off and make your own experiments. I'm not being cryptic just because I'm keeping stuff to myself. FSX has been out a long time it's a bit late to start wondering how it works now.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

With HT enabled I started up FSX boxed and FSX:SE with NO AM and screen captured the Task Manager Performance graphs during loading the flight and after the flight was finally running showed completely different layouts across the CPU (6core+HT=12LPs) all four captures. P3D was different again. Didn't take long while waiting for the kettle to boil.

 

 

Here's the screen grabs showing FSX, FSX:SE and P3D all NO AM, starting up loading scenery, and fully running:

 

FSNOAM.jpg

 

If you look at FSX and FSX:SE fully running you can se the rendering process uses only one LP of the HT core (graphs top left is LP 0). The second core has one LP occupied by the second sim job.

 

Look at P3D fully running and the LP of the rendering process has the second sim Job occupying the second LP of core zero (LP1 next on the right of LP 0).

 

So it makes sense to UNMASK only one of the first LPs of core zero when running P3D, whereas FSX and FSX:SE do that for us. The best AM for P3D on the six core with HT enabled is 340.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

So without being "cryptic" those shots show quite clearly that FSX appears to understand these are HT cores. P3D merely allows us to do what we want, but we need to do something - apply an AM. I hope that clears it up for you Luke.


Steve Waite: Engineer at codelegend.com

Share this post


Link to post
Share on other sites

Thanks for the data! I don't have FSX:SE on my main flightsim PC but I do have SP2 and P3D v3.4; I'll compare later tonight.

 

Cheers!


Luke Kolin

I make simFDR, the most advanced flight data recorder for FSX, Prepar3D and X-Plane.

Share this post


Link to post
Share on other sites

I feel like an undergraduate freshman who just accidentally walked into a graduate level lecture. :shok:

 

Its hard to follow but I am sitting down to listen anyway. I enjoy reading these discussions on Avsim between folks who have a lot more knowledge than I do. Looking forward to reading about your discoveries Luke.

 

Ted


3770k@4.5 ghz, Noctua C12P CPU air cooler, Asus Z77, 2 x 4gb DDR3 Corsair 2200 mhz cl 9, EVGA 1080ti, Sony 55" 900E TV 3840 x 2160, Windows 7-64, FSX, P3dv3, P3dv4

Share this post


Link to post
Share on other sites

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...