Skip to content

Latest commit

 

History

History
54 lines (45 loc) · 2.49 KB

Tools_FlameGraphs.md

File metadata and controls

54 lines (45 loc) · 2.49 KB

Flame Graphs

Stack traces are a powerful tool for understanding the performance of your code. They can be used to identify hotspots, and to understand the impact of optimizations. Flame graphs are a visualization of stack traces that makes it easy to see which code paths are most common, and which are the most expensive. There are multiple tools available to collect stack traces depending on the programming language and the operating system.
Here a few examples of tools that can be used to collect stack traces:

  1. Binary programs: use bcc-tools or perf
  2. Java programs: use async-profiler
  3. Python programs: use py-spy

See also:

The following examples show how to use these tools to collect stack traces and generate flame graphs.

  1. bcc-tools
  1. Java: async-profiler

    • See also Note on Spark and Flamegraphs
    • Setup: install async-profiler
    • Examples:
      # profile by time (regardless if process is on CPU or waiting)
      ./profiler.sh -e wall -d 30 -f $PWD/flamegraph1.html <pid_of_JVM>
              
      # profile on-CPU threads, without using perf
      ./profiler.sh -e itimer -d 30 -f $PWD/flamegraph1.html <pid_of_JVM>
      
      # profile on-CPU threads, using perf   
      ./profiler.sh -e cpu -d 30 -f $PWD/flamegraph1.html <pid_of_JVM>
      
      # list available events
      ./profiler.sh list <pid_of_JVM>
      
  2. Python: py-spy