FlameGraph icon indicating copy to clipboard operation
FlameGraph copied to clipboard

Add stackcollapse-trace-cmd.rb

Open igorwwwwwwwwwwwwwwwwwwww opened this issue 4 months ago • 0 comments

This is a stackcollapse processor for the output of trace-cmd, specifically the output of trace-cmd report when processing a recording with the function_graph plugin.

It is designed to be used with flamegraph.pl --flamechart, and spacers are inserted to prevent individual calls from being merged.

There is also a latency cutoff parameter that can be used to filter for slow calls.

It's written in ruby, feel free to rewrite it in perl.

Usage:

$ sudo trace-cmd record -p function_graph -l do_linkat
$ sudo trace-cmd report | MIN_LATENCY_US=500 ruby stackcollapse-trace-cmd.rb | flamegraph.pl --hash --colors=perl --flamechart > flamechart.svg

Sample flamechart:

flamechart

Upstream issue:

  • https://gitlab.com/gitlab-org/gitaly/-/issues/6425
  • https://gitlab.com/-/snippets/3757672