pprof(用于golang)不显示我的包的详细信息。

huangapple go评论98阅读模式
英文:

pprof (for golang) doesn't show details for my package

问题

我一直在尝试使用pprof对我的Go应用程序(evm-specification-miner)进行性能分析,但输出结果并不是很有用:

(pprof) top5
108.59mins of 109.29mins total (99.36%)
Dropped 607 nodes (cum <= 0.55mins)
Showing top 5 nodes out of 103 (cum >= 0.98mins)
      flat  flat%   sum%        cum   cum%
  107.83mins 98.66% 98.66% 108.64mins 99.40%  [evm-specification-miner]
  0.36mins  0.33% 98.99%      6mins  5.49%  net.dialIP
  0.30mins  0.28% 99.27%   4.18mins  3.83%  net.listenIP
  0.06mins 0.052% 99.32%  34.66mins 31.71%  
github.com/urfave/cli.BoolFlag.ApplyWithError
  0.04mins 0.036% 99.36%   0.98mins   0.9%  net.probeIPv6Stack

这是累积输出结果:

(pprof) top5 --cum
1.80hrs of 1.82hrs total (98.66%)
Dropped 607 nodes (cum <= 0.01hrs)
Showing top 5 nodes out of 103 (cum >= 1.53hrs)
      flat  flat%   sum%        cum   cum%
   1.80hrs 98.66% 98.66%    1.81hrs 99.40%  [evm-specification-miner]
         0     0% 98.66%    1.53hrs 83.93%  net.IP.matchAddrFamily
         0     0% 98.66%    1.53hrs 83.92%  net.(*UDPConn).WriteToUDP
         0     0% 98.66%    1.53hrs 83.90%  net.sockaddrToUDP
         0     0% 98.66%    1.53hrs 83.89%  net.(*UDPConn).readMsg

如你所见,大部分时间都花在了evm-specification-miner(我的Go应用程序名称)上,但我无法获得更多细节,甚至不理解这些方括号代表什么(有一个类似问题的问题,但没有得到答案)。

以下是构建和pprof命令:

go install evm-specification-miner
go tool pprof evm-specification-miner cpuprof

我甚至尝试了调试标志-gcflags "-N -l"(如此处所述:https://golang.org/doc/gdb#Introduction),但没有成功。

性能分析是通过调用pprof.StartCPUProfile()pprof.StopCPUProfile()来完成的,如此博客文章所述:https://blog.golang.org/profiling-go-programs:

func StartProfiling(cpuprof string) error {
    f, err := os.Create(cpuprof)
    if err != nil {
        return err
    }
    return pprof.StartCPUProfile(f)
}

func StopProfiling() error {
    pprof.StopCPUProfile()
    return nil
}

StartProfilingmain()的开头调用,而StopProfiling在接收到信号(中断或终止)时调用(或者程序正常终止)。此分析是在中断后获得的。

英文:

I've been trying to profile my go application (evm-specification-miner) with pprof, but the output is not really useful:

(pprof) top5
108.59mins of 109.29mins total (99.36%)
Dropped 607 nodes (cum <= 0.55mins)
Showing top 5 nodes out of 103 (cum >= 0.98mins)
      flat  flat%   sum%        cum   cum%
  107.83mins 98.66% 98.66% 108.64mins 99.40%  [evm-specification-miner]
  0.36mins  0.33% 98.99%      6mins  5.49%  net.dialIP
  0.30mins  0.28% 99.27%   4.18mins  3.83%  net.listenIP
  0.06mins 0.052% 99.32%  34.66mins 31.71%  
github.com/urfave/cli.BoolFlag.ApplyWithError
  0.04mins 0.036% 99.36%   0.98mins   0.9%  net.probeIPv6Stack

And here is the cumulative output:

(pprof) top5 --cum
1.80hrs of 1.82hrs total (98.66%)
Dropped 607 nodes (cum <= 0.01hrs)
Showing top 5 nodes out of 103 (cum >= 1.53hrs)
      flat  flat%   sum%        cum   cum%
   1.80hrs 98.66% 98.66%    1.81hrs 99.40%  [evm-specification-miner]
         0     0% 98.66%    1.53hrs 83.93%  net.IP.matchAddrFamily
         0     0% 98.66%    1.53hrs 83.92%  net.(*UDPConn).WriteToUDP
         0     0% 98.66%    1.53hrs 83.90%  net.sockaddrToUDP
         0     0% 98.66%    1.53hrs 83.89%  net.(*UDPConn).readMsg

As you can see, most of the time is spent in evm-specification-miner (which is the name of my go application), but I've been unable to obtain more details or even understand what these square brackets meant (there is a question with a similar problem, but it didn't receive any answer).

Here are the build and pprof commands:

go install evm-specification-miner
go tool pprof evm-specification-miner cpuprof

I've even tried the debug flags -gcflags "-N -l" (as noted here: https://golang.org/doc/gdb#Introduction), to no avail.

The profiling is done with calls to pprof.StartCPUProfile() and pprof.StopCPUProfile() as is explained by this blog post: https://blog.golang.org/profiling-go-programs:

func StartProfiling(cpuprof string) error {
	f, err := os.Create(cpuprof)
	if err != nil {
		return err
	}
	return pprof.StartCPUProfile(f)
}

func StopProfiling() error {
    pprof.StopCPUProfile()
    return nil
}

StartProfiling is called at the beginning of main(), and StopProfiling when a signal (interrupt or kill) is received (or if the program terminates normally). This profile was obtained after an interruption.

答案1

得分: 0

看起来更新到1.9rc1修复了它。

我的配置文件中不再有[evm-specifiation-miner](记录一下,顶部的函数甚至不是来自我的包,所以它们之前没有出现甚至更奇怪)。

英文:

Looks like updating to 1.9rc1 fixed it.

I no longer have [evm-specifiation-miner] in the profile (for the record, the top functions do not even come from my own package, so it is even weirder than they did not appear before).

huangapple
  • 本文由 发表于 2017年7月26日 00:36:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/45309074.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定