-
Notifications
You must be signed in to change notification settings - Fork 607
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
Support flame graph as an output format #401
Comments
To accomplish this right now, one has to:
|
go-torch is deprecated, use pprof instead after go1.11. We can browse web ui as follow: server nginx:
local host: start pprof: access local browser: |
I think the easiest way to implement this feature is to use scripts in https://github.com/brendangregg/FlameGraph and have a standalone command to indicate this is what the user wants. Is "-flamegraph" a good candidate due to the internal conflicting flag "-flame"? |
We should not bring in dependency on external scripts that wouldn't be a part of the executable. pprof is a part of Go runtime distribution, so everything should be contained within the pprof executable, either in the form of Go or JS code (like we do for the web UI). |
We currently use https://github.com/spiermar/d3-flame-graph as our flame graph; it would be ideal to continue to use that code. I'm not sure of the licenses for https://github.com/brendangregg/FlameGraph. And, as aalexand noted, pprof is a part of Go, so we need to be very careful with dependencies. |
ref spiermar/d3-flame-graph#33 (but nobody ever replied there) |
How about exporting self-contained HTML? That sounds easier with d3-flame-graph than interactive SVG... The only reason I want SVG is to be able to send/attach a single file that co-workers can open and zoom into.
|
Huh, saving the HTML from the browser, in simple "just HTML" mode already works! 🎉 # The redirect avoids it being suspended for reading from terminal.
go tool pprof --http :9000 --no_browser ./CMD PROFILE.heap < /dev/null &
sleep 1
for sample in {alloc,inuse}_{objects,space}; do
curl "http://localhost:9000/ui/?si=$sample" -o graph-$sample.html
curl "http://localhost:9000/ui/flamegraph?si=$sample" -o flamegraph-$sample.html
# add `source` to pages loop for annotated source view, but it's _really_ slow!
for page in top peek disasm; do
time curl "http://localhost:9000/ui/$page?si=$sample" -o $page-$sample.html
done
done
kill $! This works because data is not served in separate requests, it's simply inlined into the HTML: pprof/internal/driver/webhtml.go Line 1324 in 427632f
(and CSS and JS are inlined too).
|
I think we shouldn't bake in a requirement that the |
Some prior art: @felixge's https://github.com/felixge/pprofutils#folded can generate "Folded Stacks" format from pprof for feeding into FlameGraph toolkit. |
My way which I used to send FlameGraph file to my colleagues.
|
pprof currently supports flame graph visualization in the HTTP server mode. Sometimes it is desired to generate the flame graph visualization as a persistent report, likely as an SVG file.
The text was updated successfully, but these errors were encountered: