dongrenshi0889 2016-05-21 13:49
浏览 124
已采纳

Go应用程序的pprof CPU配置文件未显示任何示例

I'm profiling a Go application with pprof.

The application is using about 4-10% CPU and leaving it running for a short while produces a profile of around 6-11kb. This suggests to me that it should be able to sample some activity.

When I view the result, however, I see the following:

$ go tool pprof --text bigproc
1.77s of 1.77s total (  100%)
      flat  flat%   sum%        cum   cum%
     1.77s   100%   100%      1.77s   100%
$

The interesting information appears to be missing. What could be wrong?

This is on linux, with go version 1.6.1 and pprof version 2.2.1 of google-perftools (if that matters).

  • 写回答

1条回答 默认 最新

  • duanhe6464 2016-05-21 19:23
    关注

    You are mis-using the go tool pprof, because you shall specify the executable file associated with the generated profile.

    Compare this

    $ go tool pprof --text cpuprofile.prof
    680ms of 680ms total (  100%)
          flat  flat%   sum%        cum   cum%
         680ms   100%   100%      680ms   100% 
    

    with this (note main, that is the executable that produced the cpuprofile.prof)

    $ go tool pprof --text main cpuprofile.prof
    680ms of 680ms total (  100%)
          flat  flat%   sum%        cum   cum%
         350ms 51.47% 51.47%      610ms 89.71%  main.renderMandelbrotUnified
         130ms 19.12% 70.59%      130ms 19.12%  math.Log
          40ms  5.88% 76.47%       60ms  8.82%  image.(*RGBA).Set
    [cut]
    

    It's not a matter of wrong sampling: consider that around 100 samples are taken every second of execution, so even of 1.7s you should get some samples anyway (from here):

    When CPU profiling is enabled, the Go program stops about 100 times per second and records a sample consisting of the program counters on the currently executing goroutine's stack

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部