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

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

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条