From b17330c9b841b6c539c2e97d03f9407d1bfb2032 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 9 Nov 2025 18:06:13 -0500 Subject: [PATCH] docs: Update flamegraph guide --lines --- PROFILING.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PROFILING.md b/PROFILING.md index 24f163acd..faef0c726 100644 --- a/PROFILING.md +++ b/PROFILING.md @@ -14,10 +14,11 @@ The first one I recommend is async-profiler. This is available for macOS and Lin and works fairly well. See their readme for the details, but see the following to get started. 1. Download the installer from -2. Make symbolic link from `asprof` to `$HOME/bin`, assuming you have PATH to `$HOME/bin`: +2. Make symbolic link from `asprof` and `jfrconv` to `$HOME/bin`, assuming you have PATH to `$HOME/bin`: ```bash $ ln -s $HOME/Applications/async-profiler-4.2/bin/asprof $HOME/bin/asprof +$ ln -s $HOME/Applications/async-profiler-4.2/bin/jfrconv $HOME/bin/jfrconv ``` Next, close all Java applications and anything that may affect the profiling, and run sbt in one terminal: @@ -73,6 +74,15 @@ This should produce `/tmp/flamegraph.html` at the end. ![flamegraph](project/flamegraph.png) +### include line numbers + +With Scala, sometimes you would get a method name that looks like `sbt/Defaults$.$init$$anonfun$1`, which we'd have no idea which lambda expression it is pointing to. One workaround is to include the line numbers into the flamegraph by first generating in the Java Flight Recorder format. + +```bash +$ asprof -d 60 -f /tmp/flamegraph.jfr +$ jfrconv --lines /tmp/flamegraph.jfr /tmp/flamegraph.html +``` + ### running sbt with standby One of the tricky things you come across while profiling is figuring out the process ID,