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 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度