Golang pprof完整的调用图

时间:2018-04-11 09:11:25

标签: go pprof

我对pprof有点新鲜。我已经启动了CPU分析,经过一段时间检查了top25。这就是我得到的:

Showing top 25 nodes out of 174
      flat  flat%   sum%        cum   cum%
  1.01mins 21.92% 21.92%   1.10mins 23.83%  time.Time.AppendFormat
  0.26mins  5.56% 27.48%   0.26mins  5.56%  type..eq.[65]runtime.sigTabT
  0.23mins  5.07% 32.55%   0.23mins  5.07%  type..hash.[3]runtime.symbol_key
  0.15mins  3.14% 35.69%   0.15mins  3.14%  type..hash.[9]string
  ...

我认为这很酷,我只需要摆脱那个时间功能。然后意识到,我甚至不使用pkg时间内的任何东西,所以它必须是第三方lib或者其中一个内部函数。

所以我使用-web标志生成了图表,因此我可以看到哪个函数调用它,但它并没有直接显示。有没有办法跟踪它来自哪里?

1 个答案:

答案 0 :(得分:0)

我一直在使用以下方法查看所有内容。

go tool pprof -http :9999 -edgefraction 0 -nodefraction 0 -nodecount 100000 cpu.prof

这可以为您提供一个巨大的图形,可能很难遵循。为此,您可以在Web视图中单击有问题的节点,然后从左上角的“ Refine”菜单中选择“ Focus”。这提供了该节点及其所有调用方和被调用方的视图。

为了查看所有内容而使用的关键选项是:

--nodecount=<n>    Show at most so many nodes [default=80]
--nodefraction=<f> Hide nodes below <f>*total [default=.005]
--edgefraction=<f> Hide edges below <f>*total [default=.001]

您还可以在命令行上使用-focus来加快大型图形的渲染速度。

--focus=<regexp> Focus on nodes matching <regexp>
相关问题