google / google/pprof

FR: Output Folded Stacks Format

Open
#658 3 comments 0 reactions 0 assignees View on GitHub
Priority: p3 type: feat
Dominant language
Go
Stars
9.3k
Forks
671
Avg merge
1d 11h
Merged PRs (30d)
10

Description

I think if we built an exporter to [Brendan Gregg's folded stacks format](https://queue.acm.org/detail.cfm?id=2927301#:~:text=The%20folded%20stack%2Dtrace%20format,trace%2C%20followed%20by%20a%20semicolon.), we could:

1. Enable people to do differential flamegraphs using [difffolded.pl](https://github.com/brendangregg/FlameGraph/blob/master/difffolded.pl) and [flamegraph.pl](https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl), perhaps addressing the user need in #483
2. Allow post-processing the profiles using text tools like grep & sed
3. Hook into some more profile analysis tools: see [profilerpedia](https://docs.google.com/spreadsheets/d/1cVcHofphkQqk1yGeuBPVTit8HQ0oa5SlRM6gkHIagtw/edit#gid=0&range=K25), folded stacks is a very well-connected format.

I'm picturing an option like `-callgrind` and `-dot`, perhaps `-folded`.

The trouble might be that folded stacks format only accepts one output number per stack, but pprof can have multiple numbers per stack. So we'd probably have to choose the number to output with a flag, if it was ambiguous. But perhaps parts of pprof already handle this? e.g. the `-dot` output probably chooses an event to use as the weight of the graph size?

Prior art in this space: @felixge's `pprofutils folded`: https://github.com/felixge/pprofutils#folded. Felix has an extension to the folded stacks format to have numbers with multiple columns. I think that's a neat idea for representing pprof and allows roundtripping back to pprof format. It would be nice if this extension caught on, but I wonder if it might limit the interoperability with other folded stacks tools.

Another idea might be to output only one number column per-file (e.g. `pprof -folded=cpu-cycles` and `pprof -folded=instructions`), and then to roundtrip, we could output multiple files, convert both of them back to pprof, then concatenate the files with `pprof -proto `.

There are plenty of other challenges with roundtripping too (labels, filenames, mappings...) but perhaps just solving part of the problem would still be useful and enable more analyses. Anyway, I mostly wanted to open a discussion about this. Thoughts?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.