MobiFlight-WASM-Module icon indicating copy to clipboard operation
MobiFlight-WASM-Module copied to clipboard

Avoid duplicated reading RPN code execution across multiple clients

Open cpuwolf opened this issue 11 months ago • 9 comments

@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:

//RPN code execution for reading values in every frame
struct ReadRPNCode {
	std::string Code;
	int RetType; //RetType: 0:float 1:integer 2:string
	std::vector<SimVar> SimVars;
	std::vector<StringSimVar> StringSimVars;
};

‎wasm ‎1

cpuwolf avatar Mar 15 '24 20:03 cpuwolf

i am currently at FSWeekend, i will be looking at this PR next week

DocMoebiuz avatar Mar 16 '24 00:03 DocMoebiuz

@DocMoebiuz Could you take a look?

cpuwolf avatar May 05 '24 21:05 cpuwolf

Not yet tbh :(

DocMoebiuz avatar May 05 '24 21:05 DocMoebiuz

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?

DocMoebiuz avatar May 05 '24 21:05 DocMoebiuz

std::vector<SimVar> SimVars; std::vector<StringSimVar> StringSimVars;

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

cpuwolf avatar May 05 '24 23:05 cpuwolf

@cpuwolf you marked some of the comments as resolved but you might not have pushed your changes yet.

DocMoebiuz avatar Sep 07 '24 19:09 DocMoebiuz

@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

cpuwolf avatar Sep 07 '24 23:09 cpuwolf

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 avatar Sep 08 '24 04:09 DocMoebiuz