tvl-depot/tools/perf-flamegraph.nix
Vincent Ambo 1bd08e73cd fix(tools/perf-flamegraph): Get rid of most 'unknown's
This makes two main changes:

1) It disables profiling of things that aren't part of the invoked
   process (-a). This isn't particularly useful in most cases because
   it will show things like Chrome's VP9 decoding while you're
   profiling something else.

2) It tells perf about the debug symbol format, which for some reason
   isn't DWARF2 by default.

Change-Id: Ida6a54b74f1ec635fec930db7e2a2aa039dd1443
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1185
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
2020-07-16 00:37:29 +00:00

12 lines
410 B
Nix

# Script that collects perf timing for the execution of a command and writes a
# flamegraph to stdout
{ pkgs, ... }:
pkgs.writeShellScriptBin "perf-flamegraph" ''
set -euo pipefail
${pkgs.linuxPackages.perf}/bin/perf record -g --call-graph dwarf -F max "$@"
${pkgs.linuxPackages.perf}/bin/perf script \
| ${pkgs.flamegraph}/bin/stackcollapse-perf.pl \
| ${pkgs.flamegraph}/bin/flamegraph.pl
''