Skip to main content

5.5.4 Performance Flame Graph

Feature Introduction​

A flame graph is a visual representation of performance data collected by tools such as perf. It statistically analyzes the data to help easily identify performance hotspots.

http-bw

Each box in the flame graph represents a function. The width of the box indicates its execution time—thus, wider functions take longer to execute.

Each higher level ("floor") in the flame graph represents a deeper level of function calls. The topmost functions are leaf functions (functions that do not call other functions).

Code repository: (https://github.com/brendangregg/FlameGraph.git)

Supported Platforms​

PlatformExecution Environment
RDK X3, RDK X3 Module, RDK X5, RDK X5 ModuleUbuntu 20.04 (Foxy), Ubuntu 22.04 (Humble)
RDK UltraUbuntu 20.04 (Foxy)

Prerequisites​

RDK Platform​

  1. The flamegraph tool consists of two parts. The first part is the executable program perf. perf is a software performance analysis tool used to collect and output statistics about function calls within the system or a specific process. The perf tool is already included in the RDK operating system, so it can be used directly.

  2. The second part of the flamegraph tool is a script that parses perf's textual output. This script processes the text data generated by perf and produces an SVG-formatted flame graph of function calls, making it easier to observe and analyze.

Usage Instructions​

  1. Use the perf record tool to sample function calls within the RDK system and generate a perf.data file:

    root@ubuntu:~# perf record -F 99 -a -g -- sleep 60
  2. Use perf script to parse the perf.data file and generate out.perf:

    root@ubuntu:~# perf script > out.perf
  3. On your PC or RDK device, run git clone https://github.com/brendangregg/FlameGraph.git, enter the flamegraph directory, and copy the out.perf file generated in step 2 into this directory. Then use stackcollapse-perf.pl from the flamegraph toolkit to "fold" the out.perf data into out.folded:

    ./stackcollapse-perf.pl out.perf > out.folded
  4. Use flamegraph.pl to generate the SVG flame graph:

    ./flamegraph.pl out.folded > flame.svg

Steps 1 and 2 are performed on the RDK device, while steps 3 and 4 can be carried out either on a PC or on the RDK device.

Result Analysis​

Following the procedure described above, the recorded function calls within the RDK system appear as shown in the figure below: