Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add MF.Config.MAX_VARS_PER_FRAME to limit number of variables read in each frame #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 20, 2022

Conversation

DocMoebiuz
Copy link
Collaborator

This is a new PR re-using the PR from here #11

  • uses std::vector instead of std::list
  • MOBIFLIGHT_MAX_VARS_PER_FRAME has a default value of 30, but it can be set to a new value using the command MF.Config.MAX_VARS_PER_FRAME.Set.

cpuwolf and others added 3 commits May 3, 2022 14:36
1. use std::list instead of std::vector, for circular iteration
2. list max 5 SimVars reading in very frame
3. VimVars clean() needs update list iterator
use 12 for a while
@Koseng
Copy link
Collaborator

Koseng commented Aug 8, 2022

Hi Sebastian,

I also did an implementation, then still wanted to add a new command and more stuff and lost track of it.

Attached my last version, which I also tested. I have not yet looked at your code, will be interesting to see how similar it will be ;-). My code also uses std::vector and defaulted to 30.

Attached my code:
Module.zip

@Koseng
Copy link
Collaborator

Koseng commented Aug 8, 2022

Ok, I checked the code now and compared the solutions:
It is pretty similar. Sorry that I lost track, otherwise one of us could have saved some time...

Remarks:

  • I added the setting for the maximum variables per frame not globally, but as a setting of each client. So in a multi client scenario each client can decide for itself. For example one client does not care it is just using 5 variables. A second client has a lot of variables and wants to set its limit to xy for some reason.
  • And a second small optimization I added was the AbortReading. So when ClearSimVars is executed, it will quickly stop to read further variables as soon as possible. Since we can't use locks it is not perfect but a small optimization to make a conflict less probable.

@DocMoebiuz
Copy link
Collaborator Author

Ok, I checked the code now and compared the solutions: It is pretty similar. Sorry that I lost track, otherwise one of us could have saved some time...

Remarks:

  • I added the setting for the maximum variables per frame not globally, but as a setting of each client. So in a multi client scenario each client can decide for itself. For example one client does not care it is just using 5 variables. A second client has a lot of variables and wants to set its limit to xy for some reason.
  • And a second small optimization I added was the AbortReading. So when ClearSimVars is executed, it will quickly stop to read further variables as soon as possible. Since we can't use locks it is not perfect but a small optimization to make a conflict less probable.

i don't think a client specific limit makes sense because your tests show that the total number of variables read per frame is the one that matters. I don't think that we need more or less than 30 per frame - maybe 40 - but i don't expect that anyone will adjust it - i am not planning to make it configurable for Mobiflight either. I will wait for the community feedback first - and i might simply adjust the default value with one of the next releases.

what is your 2nd idea - I am not sure if i understand right.

@Koseng
Copy link
Collaborator

Koseng commented Aug 8, 2022

Just check the attached code in the first comment and look for AbortReading. The Collection might be cleared while the reading iteration is going on. Stop iterating over the collection after it is cleared.

@Koseng
Copy link
Collaborator

Koseng commented Aug 9, 2022

The AbortReading was under the assumption that the Dispatch Callback and the external Simconnect Client calls might run concurrently. I am not sure whether this is the case or completely everything is queued and runs in one thread. If there is no concurrency, then the AbortReading stuff makes no sense.

@DocMoebiuz DocMoebiuz added the enhancement New feature or request label Aug 10, 2022
@DocMoebiuz
Copy link
Collaborator Author

@Koseng did you every experiment with the precompile method for RPN? Did that make a difference?

@Koseng
Copy link
Collaborator

Koseng commented Aug 14, 2022

Yes, I tried and in my experiments it made no difference.

@DocMoebiuz
Copy link
Collaborator Author

DocMoebiuz commented Aug 14, 2022

what's your discord username?

@Koseng
Copy link
Collaborator

Koseng commented Aug 14, 2022

Wrote you in discord.

@DocMoebiuz DocMoebiuz merged commit a63c40c into main Aug 20, 2022
@DocMoebiuz DocMoebiuz deleted the 0.5.0-perf branch August 20, 2022 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants