flamegraph icon indicating copy to clipboard operation
flamegraph copied to clipboard

offline post-processing of collapsed stacks without running a workload

Open jedbrown opened this issue 9 months ago • 1 comments

I often need to analyze collapsed stacks produced using different tools or on different systems. This can be done today with a slightly awkward command (cf. https://github.com/flamegraph-rs/flamegraph/issues/259#issuecomment-1579859541)

$ flamegraph --post-process 'cat my-stacks.txt' -- /bin/true

This actually runs /bin/true under perf (or dtrace on MacOS) and sends its collapsed stacks to cat my-stacks.txt, which ignores them. This has been harmless for me on Linux, but:

  1. It's a bit weird and unintuitive
  2. It requires dtrace (and sudo) on MacOS

A similar mode can be accomplished using --perfdata, which does not require a workload (and silently ignores one if passed).

I'd like to propose:

  1. adding --bikeshed-stacks my-stacks.txt that reads from the file. It would then run --post-process (if given). It would conflict with --perfdata and with a specified workload.
  2. make --perfdata conflict with a specified workload (so it isn't silently ignored)

Would such a contribution be welcome and is this design good in principle? Any preference on naming?

jedbrown avatar Apr 07 '25 21:04 jedbrown

I'm happy to merge support for your use case. Want to throw up a PR so we can iterate a bit on the exact interface/design?

djc avatar Apr 07 '25 22:04 djc