Debugging and Profiling - tonihele/OpenKeeper GitHub Wiki
Debugging and Profiling OpenKeeper
RenderDoc
RenderDoc is a widely used graphics frame debugger.
- Getting started
- Launch OpenKeeper with the
-debug
parameter to get descriptive OpenGL object names. - If you use VSCode you can get the full dev commandline via
"console": "integratedTerminal"
. You can also just build a .jar first.
Example:java @xyz.argfile toniarts.openkeeper.Main -level mpd1 -debug
Java Flight Recorder (JFR)
JFR is built into the JVM (Java 11+).
You can record a session and view it in JMC or post-process it into flamegraphs with async-profiler tools.
"vmArgs": "-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:StartFlightRecording=delay=20s,maxsize=10M,disk=false,dumponexit=true,filename=recording.jfr,settings=profile,path-to-gc-roots=true"
This starts JFR after 20 seconds and writes a recording.jfr
file on exit.
jfrconv --threads --dot -X ".+glfwSwapBuffers|.+emitEvent" --total --simple --highlight "State[.$]|Control|System" --title 'Time spent' recording.jfr
The generated html flamegraphs can be shared e.g. via Gist and https://gistpreview.github.io/.
VisualVM
VisualVM is a free Java profiler.
There is a VSCode extension which takes care of setting correct source roots and makes launching it straightforward.
CPU Profiling
- Use Sampler or Profiler.
- Enable the Hot Spots view and sort by Self Time to spot expensive methods.
- Right-click a method and select Find in Forward Calls.
Memory Profiling
- The Heap Histogram gives an overall idea but is not too useful.
- Take a heap dump and run Compute Retained Sizes.
async-profiler
async-profiler offers accurate low-overhead profiling, but only on Linux or WSL2. A Windows version + IDE integration is available only in IntelliJ Ultimate.