-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Avoid duplicated reading RPN code execution across multiple clients #27
base: main
Are you sure you want to change the base?
Conversation
only release build works with MSFS2020
best performance for RPN execution
found below log shows NAV1 actually is no changing at all MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
ac04712
to
152c509
Compare
i am currently at FSWeekend, i will be looking at this PR next week |
@DocMoebiuz Could you take a look? |
Not yet tbh :( |
Does this work with strings too? yeah, looks like you are also treating strings. How much of an impact is this? What did you see in FPS drop? |
std::vector SimVars; so string is considered in this change. I don't have direct evidence to see FPS drop, but this change will improve FPS when we have multiple clients @DocMoebiuz think about you have multiple clients, but they have exact same simvars (L:N_FCU_HEADING), then WASM will execute "(L:N_FCU_HEADING)" multiple times in MSFS one frame update, it is totally waste of FPS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the tardy review.
// data struct for dynamically registered SimVars | ||
struct SimVar { | ||
int ID; | ||
int Offset; | ||
std::string Name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove? This was valuable in all the different log messages for troubleshooting. Was it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a dedicated commit "relocate struct SimVar->Name to ReadRPNCode->Code"
the purpose of this pull is to avoid duplicated RPN code, the "Name" here actually is is RPN code, so we need to remove redundant "Name"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is missing now in the log statements which is unfortunate.
src/Sources/Code/Module.cpp
Outdated
|
||
#if _DEBUG | ||
std::cout << "MobiFlight[" << client->Name.c_str() << "]: SimVar " << simVar.Name.c_str(); | ||
std::cout << " with ID " << simVar.ID << " has value " << simVar.Value << std::endl; | ||
std::cout << "MobiFlight[" << simVar.clint->Name.c_str() << "]: SimVar " << rpn.Code.c_str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::cout << "MobiFlight[" << simVar.clint->Name.c_str() << "]: SimVar " << rpn.Code.c_str(); | |
std::cout << "MobiFlight[" << simVar.client->Name.c_str() << "]: SimVar " << rpn.Code.c_str(); |
src/Sources/Code/Module.cpp
Outdated
if (simVar.Value == stringVal) continue; | ||
simVar.Value = stringVal; | ||
|
||
WriteSimVar(simVar, simVar.clint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WriteSimVar(simVar, simVar.clint); | |
WriteSimVar(simVar, simVar.client); |
src/Sources/Code/Module.cpp
Outdated
|
||
#if _DEBUG | ||
std::cout << "MobiFlight[" << client->Name.c_str() << "]: StringSimVar " << simVar.Name.c_str(); | ||
std::cout << " with ID " << simVar.ID << " has value " << simVar.Value << std::endl; | ||
std::cout << "MobiFlight[" << simVar.clint->Name.c_str() << "]: StringSimVar " << rpn.Code.c_str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::cout << "MobiFlight[" << simVar.clint->Name.c_str() << "]: StringSimVar " << rpn.Code.c_str(); | |
std::cout << "MobiFlight[" << simVar.client->Name.c_str() << "]: StringSimVar " << rpn.Code.c_str(); |
@cpuwolf you marked some of the comments as resolved but you might not have pushed your changes yet. |
should I resubmit the pull? I am expecting Github can do online review and revise the code realtime |
You have to make the changes in your branch and simply push the branch again. The PR will automatically update then. But simply resolving the conversation doesn't do it. |
@DocMoebiuz I have uploaded revised version |
@Koseng
While multiple clients Add(MF.SimVars.Add.xxxxRPNcodexxx) the exact same SimVars to WASM,
From MSFS2020 perspective, it is unnecessary to execute the same RPNcode several times in each frame. This is an enhancement change to reduce FPS impact
WASM will smartly execute duplicated SimVars only once in each frame.
introduce new data structure: