What is Flame graph?

A profiling visualization stacking call chains vertically, with each function's width showing its share of time.

Field: Performance Analysis

Japanese name: フレームグラフ

How to read it

A flame graph gathers the call stacks (chains of function calls) collected by a profiler into a single picture. Each box is a function on one particular call path, with callers below and callees stacked above. The width of a box is proportional to the number of samples in which that call path appeared on the stack. The wider the box, the more time was spent in that function and the functions it called. A part with nothing on top of it is time in which that function itself was running.

How it is built, with numbers

A sampling profiler records the call stack at regular intervals. Identical stacks are merged, and boxes for shared callers are drawn as one. Suppose function f is reached by only one call path and appears in 300 of 1000 samples. The box for f is 30% of the total width. If f was calling g in 200 of them, a box for g with a width of 20% sits on top of f. The remaining 100 samples, 10%, are the time of f itself.

The horizontal axis and variants

The horizontal axis does not show the passage of time. In the original form, boxes are ordered by function name so that the same function is merged together. A box on the left was therefore not necessarily executed earlier. In many cases the colors simply help tell neighboring boxes apart. Besides time spent running on the CPU, time spent waiting or memory allocation is sometimes drawn in the same format. There is also a form drawn upside down, with callers at the top.

Try it: questions about Flame graph

How is a flame graph, used to present profiling results, read?

  1. AEach function's color indicates its importance
  2. BCall stacks are stacked vertically, and each function's width shows the share of time spent in it and its callees
  3. CThe horizontal axis shows the date the program ran
Show answer and explanation

Answer: B. Call stacks are stacked vertically, and each function's width shows the share of time spent in it and its callees

A flame graph stacks callers at the bottom and callees above, drawing each box with a width proportional to the number of samples recorded. Wider boxes use more time. A wide box with nothing on top means the function itself is spending the time, while functions stacked above show time spent in callees. It reveals at a glance which call paths are expensive.

FAQ

Is it different from a flame chart?

Yes. A flame chart has the passage of time on its horizontal axis and shows what was called when. A flame graph merges identical stacks and shows shares of the whole.

Does it show how many times a function was called?

Not when it is built from samples. The width represents the number of samples, that is, a share of time. Whether a short function was called many times or a long one was called once cannot be told from the width.

Books on Performance Analysis Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary