Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Output Folded Stacks Format #658

Open
mhansen opened this issue Oct 9, 2021 · 1 comment
Open

FR: Output Folded Stacks Format #658

mhansen opened this issue Oct 9, 2021 · 1 comment
Labels
Priority: p3 Buganizer priority - P3 type: feat Buganizer type - Feature Request

Comments

@mhansen
Copy link
Contributor

mhansen commented Oct 9, 2021

I think if we built an exporter to Brendan Gregg's folded stacks format, we could:

  1. Enable people to do differential flamegraphs using difffolded.pl and flamegraph.pl, perhaps addressing the user need in [feature] Differential flamegraph #483
  2. Allow post-processing the profiles using text tools like grep & sed
  3. Hook into some more profile analysis tools: see profilerpedia, 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 <profile1> <profile2>.

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?

@aalexand
Copy link
Collaborator

aalexand commented Oct 9, 2021

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?

Yes, by default the last metric is shown. There is -sample_index option to change that. So it would be something like pprof -folded -sample_index=<number or name>.

mhansen added a commit to mhansen/pprof that referenced this issue Nov 8, 2021
mhansen added a commit to mhansen/pprof that referenced this issue Nov 8, 2021
mhansen added a commit to mhansen/pprof that referenced this issue Nov 8, 2021
mhansen added a commit to mhansen/pprof that referenced this issue Nov 8, 2021
@Louis-Ye Louis-Ye added type: feat Buganizer type - Feature Request Priority: p3 Buganizer priority - P3 labels Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: p3 Buganizer priority - P3 type: feat Buganizer type - Feature Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants