I'm developing a game where I use (SFML) C++ for the core and Lua for the actor scripts. However, I'm running into some performance issues and I'm not sure what could be wrong. I've created a test program that shows the issue I'm having.
Basically, sometimes when I call a Lua function from C++, it takes much longer to return than usual. I need my game to run at 60 fps, and it does most of the time, but occasionally one or more of the function calls will take much longer than usual.
My first thought was that it was the memory manager, but turning it off didn't seem to get rid of the spikes. I know that there are several games that use Lua, and I imagine this is not a problem for them.
People have suggested that using LuaJIT could fix the issue, so I downloaded and set up LuaJIT (with lua 5.1). I got significantly improved average times, but the spikes were just as prevalent as ever:
Gallery of 2 examples of the console results (in microseconds; for reference a frame at 60 fps is ~16700 I think):
gc off
gc on
C++ test program - http://pastebin.com/RhYnnLm3
Lua test script - http://pastebin.com/NBnAXcVD
clock
? - Ryan Stein