Machine-readable call graph data from pprof

241 views
Skip to first unread message

be...@uber.com

unread,
Jun 25, 2015, 6:34:48 PM6/25/15
to golan...@googlegroups.com
I am profiling a go server using "go tool pprof" command. I want to generate a machine-readable call graph using the dynamic profile of my program. When I run "go tool pprof" with the -tree option, I see this. I want precisely this information in a machine readable form. Specifically, I want to take a profile and generate a graph such that:
  • Nodes are functions
  • Directed edges between nodes represent that one function called another
  • The weight of edges represent the percent of calls from one function to another (exactly like the last column in the image above)
I have thought of a few potential options:
  • Parse the string output of "go tool pprof --tree"
  • Copy the code in the cmd/pprof library which generates a graph from a dynamic profile
However, I don't love either of these options because they can break in future versions of go if the pprof reporting format changes. Are there any alternatives I should consider? For example, could I use the -proto option to get a protobuf file including the graph?
Screenshot 2015-06-25 14.32.29.png

Russ Cox

unread,
Jun 26, 2015, 12:16:52 AM6/26/15
to be...@uber.com, golang-nuts
On Thu, Jun 25, 2015 at 5:42 PM, <be...@uber.com> wrote:
I am profiling a go server using "go tool pprof" command. I want to generate a machine-readable call graph using the dynamic profile of my program. When I run "go tool pprof" with the -tree option, I see this. I want precisely this information in a machine readable form. Specifically, I want to take a profile and generate a graph such that:
  • Nodes are functions
  • Directed edges between nodes represent that one function called another
  • The weight of edges represent the percent of calls from one function to another (exactly like the last column in the image above)
I think I'm missing something. How does this differ from pprof's graph output?

Russ

be...@uber.com

unread,
Jun 26, 2015, 3:44:33 AM6/26/15
to golan...@googlegroups.com, be...@uber.com
What do you mean "pprof's graph output"? Do you mean the output from the -tree option (the image I attached)? Is there some graph output I am missing?

Tamás Gulácsi

unread,
Jun 26, 2015, 4:00:40 AM6/26/15
to golan...@googlegroups.com
Yes. Read go tool pprof -help. See http://blog.golang.org/profiling-go-programs .

Pprof has a dot (graphviz) output.
Reply all
Reply to author
Forward
0 new messages