Skip to content
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

LuaIntf performance issue #93

Open
MattGuerrette opened this issue Oct 5, 2015 · 3 comments
Open

LuaIntf performance issue #93

MattGuerrette opened this issue Oct 5, 2015 · 3 comments

Comments

@MattGuerrette
Copy link

Currently, I've been profiling my game engine which utilizes luaintf to expose some of the engine class objects to lua scripts. I've noticed that there is a significant performance drop from calling functions bound using your library. Have you ever come across any performance issues with luaintf? and if so, do you have any suggestions on how to lower the impact on performance.

Thanks.

@SteveKChiu
Copy link
Owner

lua-intf should be relative light-weight, if you need better performance:

  1. do not use inheritance with lua-intf
  2. do not use STL wrapper
  3. profile the calls, and find out the bottleneck, rewrite the critical binding with lua C API

@MattGuerrette
Copy link
Author

Okay I will try exploring this more. Because the functions I was calling were quite simple for the amount of overhead I was receiving.

@MattGuerrette
Copy link
Author

So I did some more digging and even built Lua into my engine with debug symbols so I could examine where the overhead was coming from inside Lua.

Here are the lua c api calls that seem have the most problems

 -- These values are the total cpu usage over about 6 seconds of application runtime.
 -- Note, there were ~100 objects in scene all calling the same script, so the following functions
    were also called 100 times per frame.

 lua_Dcall ~ 20% cpu
      lua_vexecute ~21% cpu churn
           lua_vgettable ~10% of that 21%

After exploring what these functions actually do. Is there really that much overhead involved with retrieving the data from lua tables using the C api?

Im not sure if it will help me, but a suggestion was made to look into LuaJIT to curb some of this overhead. Let me know if u think it will help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants