---
title: "Flame Graphs from Java Flight Recorder Recordings"
canonical: "https://mnafshin.info/devtools/17-flame-graphs-from-jfr/"
author: "Afshin Amini"
date: 2026-12-02
---
# Flame Graphs from Java Flight Recorder Recordings

A flame graph is a picture of where a program spends its time. Each box is a method, and its width is the share of the samples that included it. The boxes above a method are the methods it called, so a wide box high in the picture is a place worth reading. Java Flight Recorder (JFR) from Part 10 already collects the stack samples a flame graph is built from; it only lacks the picture. Neovim cannot draw one, but it can run the tools that do and open the result.

## What a recording holds

JFR samples the stacks of running Java threads and stores each one as a `jdk.ExecutionSample` event. The `hot-methods` view from Part 10 counts only the method at the top of each stack. A flame graph keeps the whole stack, so it shows not just that a method is hot but which code called it. Our eight-second recording of the catalog app under load held 550 such events.

## Three ways to see the picture

- **JDK Mission Control** has a Flame View for `.jfr` files, described in its user guide. It is a desktop application, and we did not run it.
- **IntelliJ IDEA** shows flame graphs in its profiler, as Part 10 noted. We did not run it either.
- **The async-profiler converter** is one 136 KB Java file that turns a `.jfr` file into a single HTML page. It runs from a Neovim command line, and it is the only route we tested.

## Record the running app

Use the steps from Part 10, with the built-in `profile` settings. The recording needs requests to look at, because an idle app only records waiting threads:

```bash
PID=$(jcmd -l | awk '/ShopApp/{print $1}')
jcmd $PID JFR.start name=shop settings=profile filename=/tmp/shop.jfr
seq 1 400 | xargs -P8 -I{} curl -s -o /dev/null "localhost:8091/catalog?size=2"
jcmd $PID JFR.dump name=shop filename=/tmp/shop.jfr
jcmd $PID JFR.stop name=shop
```

The catalog app ran on port 8091 in our test. `/tmp/shop.jfr` is now a recording you can read with `jfr summary`.

## Convert it to HTML

Download the converter from the async-profiler releases page and run it. Version 4.6 needs only a JDK:

```bash
curl -fLO https://github.com/async-profiler/async-profiler/releases/download/v4.6/jfr-converter.jar
java -jar jfr-converter.jar /tmp/shop.jfr /tmp/shop.html
```

Leave out the mode flags. On a recording made by the JDK itself, `--cpu` and `--cpu-time` produced an empty graph, and we did not find out why. Without a flag we got real stacks. `--alloc` produced an allocation graph instead, and `-o collapsed` writes the stacks as text, one per line with the sample count at the end, which you can open in Neovim and search with `/`.

From Neovim, the same command runs with `:!java -jar ~/tools/jfr-converter.jar /tmp/shop.jfr /tmp/shop.html`.

## Cut away the waiting

The first graph is full of threads that wait. In ours, Tomcat's acceptor and poller threads were the two widest stacks, 136 and 139 of 911 samples, each ending in a native wait. The filter `-s runnable` left them in place.

`-I` keeps only stacks that contain a frame matching a regular expression. The expression must match the whole frame name, so add `.*` on both sides:

```bash
java -jar jfr-converter.jar -I '.*springuniverse.*' /tmp/shop.jfr /tmp/shop.html
```

That kept 192 samples whose stacks pass through the companion code. `-I 'springuniverse'` without the dots matched nothing and gave an empty graph.

## Open the page

`:lua vim.ui.open("/tmp/shop.html")` hands the file to the system opener; on Linux the command it started was `xdg-open`. Our test machine has no desktop session, so we rendered the file with headless Chrome into an image instead. The page showed a title, a toolbar of icons, and rows of boxes named after the frames. Below our `info/mnafshin` boxes sat Spring Data, Hibernate, the connection pool and the PostgreSQL driver, ending in socket reads. On a remote machine the file lives on the server, so copy it to your own computer first.

## What this does not give you

There is no flame graph inside Neovim: the picture is a browser page. IntelliJ draws it beside your code and links a box to the source; here you read the method name and jump to it with `gd` or a symbol search. We did not run JDK Mission Control, IntelliJ's profiler or Speedscope, so we cannot say how they compare. The converter is a separate download, not part of the JDK.

## Recap

- A flame graph shows whole call stacks, with width equal to a method's share of the samples; JFR already records them.
- Record with `jcmd` against the running app while it handles requests, then convert the `.jfr` file with `jfr-converter.jar`, which needs only a JDK.
- Skip `--cpu` on a JDK recording; filter with `-I '.*package.*'` to keep stacks through your own code.
- `vim.ui.open` opens the HTML page in a browser; `-o collapsed` gives text you can search in Neovim.
- Neovim draws no flame graph itself, and we tested no desktop viewer.

**Series: Neovim as a Java IDE.** Previous: [Practise the IDE keys with a game inside Neovim](/devtools/16-ide-trainer/) · Next: [Observing a running Spring Boot app from Neovim](/devtools/18-observing-a-running-app/)

## Sources

Official documentation and well-known tutorials read while writing this article. The wording here is our own.

- [async-profiler: Converter usage (jfrconv)](https://github.com/async-profiler/async-profiler/blob/master/docs/ConverterUsage.md)
- [async-profiler 4.6 release](https://github.com/async-profiler/async-profiler/releases/tag/v4.6)
- [JDK Mission Control 9: Flame Graph View](https://docs.oracle.com/en/java/java-components/jdk-mission-control/9/user-guide/flame-graphs-view.html)
- [JDK 25: The jfr command](https://docs.oracle.com/en/java/javase/25/docs/specs/man/jfr.html)
- [IntelliJ IDEA: Profiler](https://www.jetbrains.com/help/idea/cpu-and-allocation-profiling-basic-concepts.html)
- [Brendan Gregg: Flame Graphs](https://www.brendangregg.com/flamegraphs.html)
- [Ghassane Latfi: Profiling the JVM with async-profiler](https://lajvm.fr/en/profiling-the-jvm-with-async-profiler/)
- [Baeldung: JFR View Command in Java](https://www.baeldung.com/java-flight-recorder-view)
