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

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-22 03: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

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

报告相同问题?

悬赏问题

  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错
  • ¥15 vs2015到期想登陆但是登陆不上
  • ¥15 IPQ5018制作烧录固件,boot运行失败(操作系统-linux)(相关搜索:操作系统)(相关搜索:操作系统)
  • ¥20 icefall在librispeech基础上加入个人数据集
  • ¥30 keepalive高可用故障运维配置询问
  • ¥15 求帮助!国家电网内网u盘突然识别不出来了。
  • ¥15 matlab语音变速变调同时实现