Sub topic 7
Exploring a recording in JDK Mission Control
This chapter assumes you can record a .jfr file with the -XX:StartFlightRecording option, as shown in the previous chapter. It also assumes you know what a stack trace is.
JDK Mission Control (JMC) is a desktop application for reading Java Flight Recorder (JFR) files. It is a separate download. JDK 11 and later do not bundle it. Install it, then open app.jfr with File > Open File.
Start with the Automated Analysis Results page
When a file opens, JMC runs a set of rules over it and lists the findings. Each finding has a score from 0 to 100. Scores near 100 deserve attention first, and scores near 0 are usually noise.
Treat these findings as leads, not conclusions. A rule such as "Method Profiling Sample" names a hot method, but you still have to confirm it in the detailed pages.
Move through the pages
The navigation tree on the left groups the data by question.
| Page | Question it answers | Underlying events |
|---|---|---|
| Java Application > Method Profiling | Which methods use CPU time? | `jdk.ExecutionSample` |
| Java Application > Threads | Which threads are running or blocked? | `jdk.JavaMonitorEnter`, `jdk.ThreadPark` |
| Java Application > Lock Instances | Which lock objects cause waiting? | `jdk.JavaMonitorEnter` |
| Memory | How fast is the heap filling and how often does GC run? | `jdk.GarbageCollection`, `jdk.ObjectAllocationSample` |
| JVM Internals > Garbage Collections | How long are the pauses? | `jdk.GCPhasePause` |
| Event Browser | Everything that was recorded | all events |
Read the stack trace view
On the Method Profiling page, the Stack Trace view shows the sampled stacks as a tree. The top frame is the method that was executing when JFR took the sample. Select a frame to see which callers led to it. In the Slow example from earlier, you would expect to see StringBuilder and array-copy frames near the top, called from main.
Use the Event Browser when the pages do not answer your question. Filter by event type, sort by duration, and open a single event to see its stack trace and fields.
Check the recording before you trust it
Many wrong conclusions come from a weak recording. Check these first:
- Duration. JFR takes a sample every 20 ms with the default settings and every 10 ms with
settings=profile. A 5-second recording may hold only a few hundred samples. Hot-method percentages from so few samples are unreliable. - Settings. With
default, some events are off or sampled coarsely. Record withsettings=profilewhen you need detailed data. - Warmup. The first seconds include JIT compilation and class loading. Compare a window in steady state with the start.
- Time range. Drag-select a range in the timeline to filter every page to that window. Use this to isolate a slow period.
Cross-check from the command line
You can also inspect a recording without the GUI. This helps on a server that has no display.
jfr summary app.jfr
jfr print --events jdk.ExecutionSample app.jfr | head -40jfr summary lists each event type with its count, so you can confirm that the events you expect were recorded. jfr print prints individual events, including their stack traces.
Exercise
A JMC page shows one method at 40% of samples, but the recording lasted only 3 seconds with the default settings. Give two reasons to be cautious, and say what you would do.
Show answer
At 20 ms per sample, 3 seconds gives only about 150 samples, so the percentage has a wide margin of error. The recording may also include warmup, which is not representative of steady state. Record again for longer (for example 60 seconds) with settings=profile, during steady load, and check that the method is still the top frame.