liveBook · Manning

Flame graph

As explained in Troubleshooting Java: Read, debug, and optimize JVM applications

A visualization of an execution stack in which methods are arranged by call level and their widths indicate relative execution time.

A flame graph shows profiled execution as a vertical stack: the bottom is where the thread starts, and each level above contains methods called by the level below. It adds a view of relative execution time to the call tree, helping reveal potential latencies. section 8.3

Read the graph by following the call levels and comparing widths:

  • Methods on the same level share a caller below them. section 8.3
  • A method’s width represents its execution time relative to its caller; sibling widths together span the caller’s width. section 8.3
  • Colorization rules can highlight selected layers and help compare execution times. section 8.3

Compare sibling methods

In the example, ProductService.getProductNamesForPurchases() calls ProductRepository.findById() and PurchaseRepository.findAll(). Both appear on the same level, but findAll() is wider, indicating more execution time relative to their caller. section 8.3

Figure 8.17 The flame graph is a stack representation of the execution trace. Each level shows the methods called by the level below. The first (bottom) level of the stack is the start of the thread. This way, we see the execution stack vertically, while the flame graph horizontally indicates the time spent by each level relative to the level below.

Use the execution-stack diagram to see how call levels map to the flame graph’s vertical and horizontal dimensions. section 8.3

How Troubleshooting Java: Read, debug, and optimize JVM applications covers it

How deep it goes
Explains call levels and relative widths with a worked example, but does not detail the profiling process itself.
Examples
Compares ProductRepository.findById() with PurchaseRepository.findAll() beneath ProductService.getProductNamesForPurchases().
What it assumes
Assumes a profiled execution and a generated call tree; does not teach how to collect profiling data.
What you can do after
Diagnose potential execution latencies by comparing method widths and highlighting selected graph layers.
How it connects
Distinguishes flame graphs from call graphs and connects them to execution stacks, call trees, and profiling.

Also explained in

Compare how 3 books explain flame graph →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java: Read, debug, and optimize JVM applications. The section links point to the parts of the book it draws on.