How do I install this?

This Minetest mod lets you use LuaJIT's builtin profiler. This profiler is good for pinpointing expensive parts of mod code.

How to Use

  • Add the mod to the secure.trusted_mods list.
  • Enable the mod.
  • In-game start the profiler with /jitprofiler_start 1 <filename>. The profiling data will be written to <worldpath>/jitprofiles/<filename>.
  • Collect data for a while.
  • Stop profiling with /jitprofiler_stop or by exiting the world.
  • Download FlameGraph if you haven't done so.
  • Create a flame graph SVG with ./ <worldpath>/jitprofiles/<filename> > graph.svg.
  • Open the SVG with your browser or another viewing program.
  • The top level of each stack snapshot will be "C", "G", "I", "J", or "N", representing C code, garbage collection, interpreter, JIT compilation, or compiled code, respectively.


  • This mod can cause the game to hang somehow. Most of the profiling data collected before the hang is saved.
  • Sometimes a lot of C code execution is reported in suspicious places. I think this represents time taken by the Minetest engine, but I don't know why the profiler thinks the code is executed inside a Lua function.
  • Using this mod with Mesecons luacontrollers can cause crashes for some reason.



Do you recommend this mod?

  • Majorly improved performance of my game/server

    I maintain NodeCore, a very complex game spanning over 20k lines of code. For some time (apparently years), a serious performance issue had been slowly building up on my NodeCore server, causing bad lag spikes, and my players and I were having no luck figuring out the cause. Minetest's built-in profiler was no help, and I had tapped out its extremely limited abilities a long time ago.

    After being pointed to the JIT Profiler, and figuring out how to use it and interpret the results (read the description carefully), it helped solve the performance problem very quickly (a raycast happening too early in a sequence of checks), and also identified other performance issues that I hadn't even detected yet (uncached privilege checks, dynamic lighting checks, and more).

    I highly recommend all modders who care about quality use this tool and test performance of all their packages. It is a little complex to run but very much worth it.

    (more in comments)

  • A must-have for writing performance-critical code

    Minetest's profiler provides insufficient granularity for doing any serious profiling. Sure, in larger games it may point you towards the culprit, but that often still is a large globalstep or mapgen function.

    More often, you already know the culprit - mapgen, in our case - and want to optimize it. To do so, you need a maximum of granularity, down to every function call, every vector operation, to be able to micro-optimize the hottest spots where it matters. The LuaJIT profiler provides this granularity and this mod makes it accessible (without having to go through the hassle of reinventing this mod).

    Back to mapgen: After algorithmic optimizations were exhausted, this mod allowed me to gain a 2x speedup, bringing mapgen to an acceptable performance, by confirming that certain vector operations were better off localized and helping me uncover a nasty bug in my memoization (which wasn't working).

    You only have 100ms between two globalsteps; Minetest is mostly single-threaded. Taking any more time will create noticeable lag. Thus practically all mapgen, ABMs, pathfinding, mob steps, and some expensive globalsteps are performance-critical.

    Adoption of this mod will hopefully cause the widespread performance issues observed across the mod landscape to slowly cease existence.

  • Very useful

    It's very useful because it tells you how much time each function takes. Thanks to this I've been able to optimize my mod's performances by a lot :D

  • The best profiler (yes really)

    The mod is very simple to use (only tested on linux). One of the best tools to find out where CPU time is being used unnecessarily. Conclusion: I love this mod