Chapter 18. Getting started with flamegraphs


As a system administrator, you can use flamegraphs to create visualizations of system performance data recorded with the perf tool. As a software developer, you can use flamegraphs to create visualizations of application performance data recorded with the perf tool. Sampling stack traces is a common technique for profiling CPU performance with the perf tool. Unfortunately, the results of profiling stack traces with perf can be extremely verbose and labor-intensive to analyze. flamegraphs are visualizations created from data recorded with perf to make identifying hot code-paths faster and easier.

18.1. Installing flamegraphs

You must install the required packages to start using flamegraphs.

Procedure

  • Install the flamegraphs package:

    # dnf install js-d3-flame-graph

18.2. Creating flamegraphs over the entire system

You can visualize performance data recorded over an entire system by using flamegraphs.

Prerequisites

Procedure

  • Record the data and create the visualization.

    # perf script flamegraph -a -F 99 sleep 60

    This command samples and records performance data over the entire system for 60 seconds, as stipulated by use of the sleep command, and then constructs the visualization which is stored in the current active directory as flamegraph.html. The command samples call-graph data by default and takes the same arguments as the perf tool, in this particular case:

    -a
    Stipulates to record data over the entire system.
    -F
    To set the sampling frequency per second.

Verification

  • For analysis, view the generated visualization:

    # xdg-open flamegraph.html

    This command opens the visualization in the default browser:

Flamegraph showing CPU activity across all CPUs

18.3. Creating flamegraphs over specific processes

You can use flamegraphs to visualize performance data recorded over specific running processes.

Prerequisites

Procedure

  • Record the data and create the visualization.

    # perf script flamegraph -a -F 99 -p ID1,ID2 sleep 60

    This command samples and records performance data of the processes with the process ID’s ID1 and ID2 for 60 seconds, as stipulated by use of the sleep command, and then constructs the visualization which will be stored in the current active directory as flamegraph.html. The command samples call-graph data by default and takes the same arguments as the perf tool, in this particular case:

    -a
    Stipulates to record data over the entire system.
    -F
    To set the sampling frequency per second.
    -p
    To stipulate specific process ID’s to sample and record data over.

Verification

  • For analysis, view the generated visualization:

    # xdg-open flamegraph.html

    This command opens the visualization in the default browser:

Flamegraph

Each box in the flamegraph represents a different function in the stack. The y-axis shows the stack depth. The top box in each stack represents the function that was on-CPU and the remaining boxes represent ancestry. The x-axis displays the population of the sampled call-graph data.

The x-axis sorts functions by sample count, not time. Children appear in descending order of their total samples. Box width represents frequency on-CPU. Wider boxes indicate functions or ancestors captured in more samples.

Procedure

  • To reveal the names of functions which may have not been displayed previously and further investigate the data, click the box within the flamegraph to zoom into the stack at that given location:

    Zoomed-in flamegraph
  • To return to the default view of the flamegraph, click Reset Zoom.

    Important

    Boxes representing user-space functions may be labeled as Unknown in flamegraphs because the binary of the function is stripped. Install the debuginfo package or compile your local application with debugging information enabled. Use the -g option in GCC, to display the function names or symbols in such a situation.

    Flamegraph visualization
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top