Re: optimal settings (jit.opt) and tips for a large codebase? (take two)

  • From: Elias Hogstvedt <eliashogstvedt@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 22 Sep 2015 09:11:09 +0200

My codebase is about 100 000 lines or 310 000 words (with excessive
whitespace and auto generated lua files stripped). However not all of that
is run at the same time of course. You can see for yourself here
https://github.com/CapsAdmin/goluwa

When profiling and the performance is good most of the time is spent in
drawing which is expected but when it tanks the profiler shows time spent
all over the place. If I load a complex scene the performance is initially
good but if I call jit flush even without opening the gui or anything the
performance will drop permanently like it does when doing a lot of things
like opening the editor and restarting the renderer.

I have some counter that shows the amount of garbage in MB so I've always
had an eye on it. The amount of gargabe doesn't seem abnormally high. It's
crawls from about 70 to 130 mb until it collects on a complex scene and I
don't feel the collection when moving around. Calling
collectgarbage("step", 30) makes sense so I'll play around with that,
thanks.

On Tue, Sep 22, 2015 at 12:34 AM, Caswal Parker <caswal@xxxxxxxxxxxxxxxxxxxx

wrote:

How large is your code base? I also use LuaJIT 2.0.3 for all of my game
code and get stable frame rates. My lua scripts folder is about 5.2mb
(although 1.8mb of that is Automatically generated start up and config that
only get's run once.). Of course this is a very vague metric. I have never
tweaked the jit.opt settings.

Have you done any profiling to find the true cause? Are you certain this
is a JIT issue, and not your GUI code creating a lot of transient objects
that are loading up and stalling the garbage collector? The garbage
collector is pretty slow, and can cause stalls/stutters. I call
a collectgarbage("step", 30) each frame. With the step size tweaked by hand
to get the result I want.

On Tue, Sep 22, 2015 at 6:40 AM, Elias Hogstvedt <eliashogstvedt@xxxxxxxxx
wrote:

I've turned all my data to structs and removed the patch just to make
sure it's not that. I've also tweaked some options which helpes increasing
maxtrace and maxsnap seems to help a lot.

However the fps will still tank after stressing the jit compiler too much
by doing random things like opening the editor or restarting the renderer.
I've also noticed that if I do jit.flush() it will never recover. Maybe I'm
hitting some limit which flushes everything and it never recovers? I'm
using latest 2.1 from git.

On Fri, Sep 18, 2015 at 1:03 AM, Elias Hogstvedt <
eliashogstvedt@xxxxxxxxx> wrote:

I have a fairly large game engine project written in entirely in luajit
and I'm having some performance issues when rendering complex scenes. It's
gotten to a point where if I turn jit off while rendering a complex scene
performance can drop from 150 to 5 fps.

Things that help so far:
- Increasing maxmcode with jit.opt - this drastically improves
performance
- Apply the attached patch if using nested unions - this also
boosts performance but I suppose you could avoid using nested unions too.
(I use them to get swizzle-like functionality for data structures)
- Increase max unroll settings with jit.opts - this might
increase machine code size but it does seem to help with performance.

My issue now is performance dropping and then staying low after doing
other things in the engine (mainly using a gui).

For instance after loading a complex 3d scene the fps stay below 10 for
a bit while luajit is compiling and then eventually go up to 100 fps. This
is fine and expected but when I open another complex scene, like the editor
gui, performance will drop the same way and go up. But sometimes depending
on the complexity of the 3d scene and jit.opt settings the fps will stay
permanently low. I've experimented with increasing maxtrace, maxrecord, etc
but it just seems to worsen the problem.

Having some of the max* settings too high seems to crash luajit too
randomly while compiling.



The attached patch for unions was originally posted here:
http://permalink.gmane.org/gmane.comp.lang.lua.luajit/5489
Mike seems somewhat reluctant to apply the patch. Maybe it needs to be
tested or improved/done properly?





--

---------------------------------------------------------------------------------

Caswal Parker
Co-Owner/Lead Programmer - Camshaft Software
Skype name: caswal
http://camshaftsoftware.com

Other related posts: