Jump to content
The simFlight Network Forums

FSUPC7 reading lua script much slower than FSUIPC5


Gokce

Recommended Posts

I am using same lua script in FSUIC5 and it works very well but when i try same script even with performance improvement modifications applied to the script and run in FSUIPC7, it read script much slower when i watch from the console. Is there any configuration to make it faster maybe from FSUIPC7.ini file or is it an issue about new version? Can you advice any solution about it?

Link to comment
Share on other sites

There should be no difference in the actual execution of lua scripts, as the lua engine in FSUIPC7 is identical to the one in FSUIPC5. Any difference will be due to the simulator being used, and also, as FSUIPC5 is an embedded dll in P3D, and FSUIPC7 is a separate application, there will be a slight overhead with the communication to the FS (via SimConnect).

What exactly is much slower? Can you show me the script, and both an FSUIPC7.log file and FSUIPC5.log file showing this performance issue.

Link to comment
Share on other sites

I have uploaded FSUIPC5 and FSUIPC7 console records to the Youtube. You can check the videos' links below. In both FSUIPC i ran same script (only offsets are differant) and did almost same process in both (even i tried to do more triggers on FSUIPC7). But as you can see FSUIPC5 triggers much more faster and also does more triggers and FSUIPC7 triggers way much less times and much slower.


FSUIPC7 LINK: 

FSUIPC5 LINK: 

 

Link to comment
Share on other sites

My friend sent you the files via PM, and that trigger means function triggers by an event in lua script. For example when we send 50 event triggers to the fsuipc, 5 triggers all 50 of em without problem, but 7 takes only few of them like 5-7 times and triggers the event. That event on the video is heading encoder up/down event. fyi.

Link to comment
Share on other sites

Your log files do not show the exaamplecode.lua running. If you want me to spend  time looking into this. I need to see the actual scripts that are running, and the log files showing these scripts running., and also a description of where in the log file you think that there is a performance issue. Also, if waiting for an event on an offset change, you should add FSUIPC logging for that offset.

Note also the examplecode.lua you provided is waiting for am offset change in the PMDG offset area. This is updated on reception of the client data from PMDG. The PMDG aircraft for P3D and MSFS are very different, and I suspect the performance issue relates to the delivery & reception of the PMDG data, not the performance of the event waiting for this data change.

9 minutes ago, naizo said:

My friend sent you the files via PM, and that trigger means function triggers by an event in lua script. For example when we send 50 event triggers to the fsuipc, 5 triggers all 50 of em without problem, but 7 takes only few of them like 5-7 times and triggers the event. That event on the video is heading encoder up/down event. fyi.

Try logging the offset that you are waiting for the event on. This will show you when the offset value has changed, and when the event should be triggered. If FSUIPC7 is seeing less PMDG offset changes than FSUIPC5, then the PMDG aircraft is sending less client data packets, and you should ask  about this on the PMDG forums.

I think the differences in performance you are seeing are due to the PMDG aircraft, not FSUIPC.

Link to comment
Share on other sites

We are not asking for any events to PMDG, we send a string to FSUIPC by a hardwere device via com port and when lua script finds that string does ipc.control(eventID, parameter)  and turns the heading encoder in simulator up or down. We are on sending part yet for MSFS also i ve tried to receive offsets from the sim, that works aswell when changed. But lua script somehow running so slow on fsuipc7. I am checking every step from the console while testing the code.

Quote

Your log files do not show the exaamplecode.lua running. If you want me to spend  time looking into this. I need to see the actual scripts that are running

The script we have sent you is the actual script already, just removed unnecessary parts of it. When i run the script we've sent you, exactly same thing happens, you do not need whole code tbh. Even if i print only "Hello world" still FSUIPC7 writes it much slower than FSUIPC5 (again printing "hello world" by a trigger string sent from a hardwere device via com port. Maybe issue is about serial communication because i send that trigger strings from com port to FCUIPC.

Quote

I think the differences in performance you are seeing are due to the PMDG aircraft, not FSUIPC.

Can't say it's PMDG cuz those happening before sending or receiving events/offsets, also as i said even print("hello world") is slower, it can't be about PMDG 🙂  I just tested print("hello world") again; sent around 40-60 trigger string around in 3 seconds to both of them, i couldnt count FSUIPC5 hello world prints but can easily count for FSUIPC7 and its just 13 times.

Link to comment
Share on other sites

Also i had similar (just i think it's similar maybe not) issue with c++ coding before, serial port was waiting 1000ms to send another request, solution was changing serial timeout time with Serial.setTimeout(10); default was 1000. I checked FSUIPC7.ini file if there is any configuration about it but unfotunately i could not found. Even tried to find script line reading speed but none 😞

Link to comment
Share on other sites

2 hours ago, naizo said:

We are not asking for any events to PMDG

You have  an event registered on offset 0x652C, which is an offset in the PMDG offset area:

Quote

          event.offset(0x6 52C, "UW", "MCP_Heading")

If you are not using PMDG aircraft, how is that offset populated?

2 hours ago, naizo said:

we send a string to FSUIPC by a hardwere device via com port and when lua script finds that string does ipc.control(eventID, parameter)  and turns the heading encoder in simulator up or down.

Ok, then this is  the event.com one:

Quote

     event.com(Arduino_Com_Port, 50, 1, "Arduino_Data")

There was a change in com read/write loops in 7.3.18:

Quote

FSUIPC7 v7.3.18 released on 15th March 2023 contains the following changes:
  - new ini parameter added: ComWriteLoopTime. Default value 10ms
  - default value of ComReadLoopTime changed from 20ms to 10ms
...

You can try reverting to the previous values by  setting:;
     ComReadLoopTime=20
     ComWriteLoopTime=20
in the [General] section of your FSUIPC7.ini file.

2 hours ago, naizo said:

But lua script somehow running so slow on fsuipc7. I am checking every step from the console while testing the code.

As I have said, the lua interface in FSUIPPC7 is exactly the same as that in FSUIPC5. If it is slower, I have no idea why and cannot do anything about this.

2 hours ago, naizo said:

The script we have sent you is the actual script already, just removed unnecessary parts of it. When i run the script we've sent you, exactly same thing happens, you do not need whole code tbh. Even if i print only "Hello world" still FSUIPC7 writes it much slower than FSUIPC5 (again printing "hello world" by a trigger string sent from a hardwere device via com port. Maybe issue is about serial communication because i send that trigger strings from com port to FCUIPC.

Quote

I think the differences in performance you are seeing are due to the PMDG aircraft, not FSUIPC.

Can't say it's PMDG cuz those happening before sending or receiving events/offsets, also as i said even print("hello world") is slower, it can't be about PMDG 🙂  I just tested print("hello world") again; sent around 40-60 trigger string around in 3 seconds to both of them, i couldnt count FSUIPC5 hello world prints but can easily count for FSUIPC7 and its just 13 times.

But I need to see the actual script running to make any sense of the log - there is no point sending me a different script than the one running, so if you are going to remove parts of it then I need to see the log generated with that script, not the original

So can I assume that your issue is with the lua com interface only? I am not in a position to be able to test the com interface here. Try with those parameters I mentioned above  to see if that makes a difference. I will go through any other com interfaces changes to see if they could possibly cause this, and maybe provide you with an older version to test.

You can also try logging com data to see if that reveals anything. Suggest you initially do this with a minimal lua script that shows your issue, like your Hello World example. To log com data,
      in FSUIPC7, enter a Log -> Custom value of x40.
      in FSUIPC5, add the following to the [General] section of your FSUIPC5.ini file:
            Debug=Please
            LogExtras=0x40

2 hours ago, naizo said:

Also i had similar (just i think it's similar maybe not) issue with c++ coding before, serial port was waiting 1000ms to send another request, solution was changing serial timeout time with Serial.setTimeout(10); default was 1000. I checked FSUIPC7.ini file if there is any configuration about it but unfotunately i could not found. Even tried to find script line reading speed but none 😞

That is basically what those ini parameters do. However, they are set to 10 in FSUIPC7 and 20 in FSUIPC5, so FSUIPC7 should be faster...

Link to comment
Share on other sites

Note your issue seems to be similar to this one, for which the ComWriteLoopTime ini parameter was added, and when the defaults were changed from 20 to 10ms:

Try playing around with different values for those parameters to see if this improves things.

 

Link to comment
Share on other sites

Thanks for your reply,

1 hour ago, John Dowson said:
4 hours ago, naizo said:

We are not asking for any events to PMDG

You have  an event registered on offset 0x652C, which is an offset in the PMDG offset area:

Quote

          event.offset(0x6 52C, "UW", "MCP_Heading")

If you are not using PMDG aircraft, how is that offset populated?

Yes you right, but i mean i am not using that event.offset while testing other code, i left that code in script just for information to you to give you idea how it works.

1 hour ago, John Dowson said:

Ok, then this is  the event.com one:

Quote

     event.com(Arduino_Com_Port, 50, 1, "Arduino_Data")

yeah that one.

1 hour ago, John Dowson said:

But I need to see the actual script running to make any sense of the log - there is no point sending me a different script than the one running, so if you are going to remove parts of it then I need to see the log generated with that script, not the original

I will change ComReadLoopTime value and do the other checks tomorrow and will share my findings. If problem is not solved gonna run the script and save log file to send you again, so maybe you can find out.

Link to comment
Share on other sites

26 minutes ago, naizo said:

If problem is not solved gonna run the script and save log file to send you again, so maybe you can find out.

Please do this with the com data logged,, and with a simple script that shows this issue. Also set Log -> Extras.

Link to comment
Share on other sites

I've sent you files via PM.

But i explain the issue here again.

Barely FSUIPC7 console flow is 100x (or maybe even more) slower than FSIUPC5 and 6. Even when i use just print commands on the script console flow is so slow, not about sending/receiving events data, it's just reading code slow somehow. After all Lua Script is Lua Script, doesn's matter where you run it, it's such a lightweight code written on notepad. Doesn't have layered architecture or complex structure. FSUIPC7 reading 1000 lines in around 100-300ms but FSUIPC5 and 6 reads 1000 lines in 1ms. These are approximate but show the difference clearly. What was changed on FSUIPC7 about it?

Link to comment
Share on other sites

There have been various minor changes but none that could affect the performance so much. There was one change to locking which could affect performance with event-based lua scripts, but the change was made so that events would not be lost (i.e. previously an event would be lost if a required resource was being used, but with this change the lua thread waits for the resource). I have reversed this update in the attached version (7.3.21c) if you could try it, to see if it is this change that is making the difference: FSUIPC7.exe

If its not this, I really have no idea why the general lua performance has changed, and am also at a loss as to how to investigate this.

Is more PC more heavily loaded when running MSFS compared to P3D?

Link to comment
Share on other sites

8 minutes ago, John Dowson said:

if you could try it

I will try.

9 minutes ago, John Dowson said:

Is more PC more heavily loaded when running MSFS compared to P3D?

Yea ofc, due to graphics differance but i am testing on a strong computer, it's not that kinda performance issue. Even when MSFS installed, suggested graphics level is ultra, but changing it even lower won't effect to FSUIPC7 script reading speed.

Link to comment
Share on other sites

  • 2 weeks later...
On 6/5/2023 at 2:36 PM, John Dowson said:

I will do some general lua performance tests here at some point, but not sure when I will have time to do this.

I have made some performance tests and can confirm that lua scripts in FSUIPC7 run around 8 times slower in FSUIPC7 compared to FSUIPC6. Noy sure why at the moment, I will investigate and let you know if I find anything.

Link to comment
Share on other sites

  • 9 months later...

@naizo I have looked at this again and it seems that lua scripts run a lot slower when FSUIPC7 is auto-started by MSFS. if it is started manually, it runs a lot faster.
Are you auto-starting FSUIPC7 via the EXE.xml (i.e. using the auto-start component)? If so, can you try manually starting FSUIPC7 - just exit it when it starts and then restart it manually., Do you see a performance improvement?

I noticed this when running the example record to csv.lua script. If I run this when FSUIPC7 is auto-started, the data is logged at roughly 800ms intervals, but if I exit and start FSUIPC7 manually, the rate goes up to around 63ms intervals, more than 10 times faster.

I will update the documentation with this information, and report this to Asobo to see what, if anything,  can be done.

John

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.