joe
2014-09-20 02:25:22 UTC
I'm working on a game using a heavily modified version of the MOAI
game engine and LuaJIT 2.0.2. Almost all the non-MOAI parts of the
game are implemented in Lua, so Lua takes a significant amount of our
frame time (more than half). Switching to LuaJIT from traditional Lua
gave us a significant performance boost. However when JIT compilation
is enabled, we actually experience a significant performance decrease
compared to when it is disabled, roughly 15-20%. I've spent weeks now
trying to make the game more JIT friendly, with no measurable benefit.
Our lua code is largely pure Lua with few calls into C++, so seems to
be an ideal candidate for LuaJIT compilation but we are not seeing the
results.
I've tried analyzing the trace failures with the tools in v.lua, and
I've gotten rid of hundreds of the most common NYI issues we have in
our code, replacing inner loop C functions with ffi versions, getting
rid of pairs() iterations, getting rid of string concats, etc. I've
done all this with pretty much no measurable benefit. I can tell from
checking the output from v.lua that I am in fact fixing those
problems, but I am still not seeing any performance gains, and I'm
running out of things to try.
So if I may I'd like to ask a few questions:
Is it expected that enabling JIT will degrade performance for some
applications?
What might cause that, simply the overhead of attempting to compile
the traces with no performance benefit to offset it?
Is finding and fixing the most common NYI issues not the best way
address the issue?
Is there anything else I can do to diagnose the problem, or is it most
likely that our application will not benefit from JIT compilation, and
I should move on to higher level Lua optimizations?
Thanks,
Joe Virskus
Double Fine Productions
game engine and LuaJIT 2.0.2. Almost all the non-MOAI parts of the
game are implemented in Lua, so Lua takes a significant amount of our
frame time (more than half). Switching to LuaJIT from traditional Lua
gave us a significant performance boost. However when JIT compilation
is enabled, we actually experience a significant performance decrease
compared to when it is disabled, roughly 15-20%. I've spent weeks now
trying to make the game more JIT friendly, with no measurable benefit.
Our lua code is largely pure Lua with few calls into C++, so seems to
be an ideal candidate for LuaJIT compilation but we are not seeing the
results.
I've tried analyzing the trace failures with the tools in v.lua, and
I've gotten rid of hundreds of the most common NYI issues we have in
our code, replacing inner loop C functions with ffi versions, getting
rid of pairs() iterations, getting rid of string concats, etc. I've
done all this with pretty much no measurable benefit. I can tell from
checking the output from v.lua that I am in fact fixing those
problems, but I am still not seeing any performance gains, and I'm
running out of things to try.
So if I may I'd like to ask a few questions:
Is it expected that enabling JIT will degrade performance for some
applications?
What might cause that, simply the overhead of attempting to compile
the traces with no performance benefit to offset it?
Is finding and fixing the most common NYI issues not the best way
address the issue?
Is there anything else I can do to diagnose the problem, or is it most
likely that our application will not benefit from JIT compilation, and
I should move on to higher level Lua optimizations?
Thanks,
Joe Virskus
Double Fine Productions