Create convenience script to capture perf-record and make flamegraph output

These helper scripts should make it easy to quickly capture a profile and generate a flamegraph with a minimum of arguments.

They use a timer-based event to trigger periodic sampling of stack traces. Those stack traces are then aggregated and presented as a flamegraph.

Use cases:

  • single process
  • all processes owned by a specific user
  • all active processes on the host

Add these scripts to the gitlab-server::perf-tool recipe. They will also require cloning https://github.com/brendangregg/FlameGraph.git to an easily accessible location (maybe /opt?).

Consider using some opinionated options, such as:

  • flamegraph.pl --hash to assign colors based on function name (rather than random). This makes two graphs easier to visually compare. It also makes it easier to notice a commonly called function appearing in multiple places.
  • stackcollapse-perf.pl --kernel together with flamegraph.pl --colors perl makes kernel stack frames use an orange hue and userspace stack frames use a red hue.

Example of the combination of both of the above suggestions:

$ cat perf-script.out | ./stackcollapse-perf.pl --kernel | ./flamegraph.pl --hash --colors perl > temp.svg

temp.svg

Edited by AnthonySandoval