lua-intf
lua-intf copied to clipboard
LuaIntf performance issue
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.
lua-intf should be relative light-weight, if you need better performance:
- do not use inheritance with lua-intf
- do not use STL wrapper
- profile the calls, and find out the bottleneck, rewrite the critical binding with lua C API
Okay I will try exploring this more. Because the functions I was calling were quite simple for the amount of overhead I was receiving.
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.