go tool pprof 字段翻译

一直对 go tool pprof xxx.prof 字段不是很了解,群里人发了官方文档,翻一下做个记录

(pprof) top10
Total: 2525 samples
     298  11.8%  11.8%      345  13.7% runtime.mapaccess1_fast64
     268  10.6%  22.4%     2124  84.1% main.FindLoops
     251   9.9%  32.4%      451  17.9% scanblock
     178   7.0%  39.4%      351  13.9% hash_insert
     131   5.2%  44.6%      158   6.3% sweepspan
     119   4.7%  49.3%      350  13.9% main.DFS
      96   3.8%  53.1%       98   3.9% flushptrbuf
      95   3.8%  56.9%       95   3.8% runtime.aeshash64
      95   3.8%  60.6%      101   4.0% runtime.settype_flush
      88   3.5%  64.1%      988  39.1% runtime.mallocgc

原文:

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. The profile has 2525 samples, so it was running for a bit over 25 seconds. In the go tool pprof output, there is a row for each function that appeared in a sample. The first two columns show the number of samples in which the function was running (as opposed to waiting for a called function to return), as a raw count and as a percentage of total samples. The runtime.mapaccess1_fast64 function was running during 298 samples, or 11.8%. The top10 output is sorted by this sample count. The third column shows the running total during the listing: the first three rows account for 32.4% of the samples. The fourth and fifth columns show the number of samples in which the function appeared (either running or waiting for a called function to return). The main.FindLoops function was running in 10.6% of the samples, but it was on the call stack (it or functions it called were running) in 84.1% of the samples.

翻译:

当CPU profiling开启,Go程序1秒钟停止100次,来对goroutine栈调用进行连续采样并记录

本次调试总计有2525个采样,所以他执行时间超过25s

go tool pprof 输出里,采样里的每个function有一行信息对应

前面2列是关于function在运行状态所在的所在的原始总样本数量和总比例

runtime.mapaccess1_fast64 这个function在298个样本里运行过,或者占总比例的11.8%

top 10 的输出是按照样本数倒叙排列的

第3列显示运行总是占列表里的比例,前面3行占样本的32.4%(第3行第3列:11.8%+10.6%+9.9%)

第4,5列展示function出现过的样本数和比例

main.FindLoops 这个function只在10.6%的样本里执行过,但是在84.1%的调用栈里出现过

原文地址: https://blog.golang.org/profiling-go-programs

我来评几句
登录后评论

已发表评论数()

相关站点

热门文章