gpt4 book ai didi

go - pprof(对于 golang)不显示我的包的详细信息

转载 作者:数据小太阳 更新时间:2023-10-29 03:24:39 26 4
gpt4 key购买 nike

我一直在尝试使用 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 应用程序的名称)中,但我一直无法获得更多细节甚至理解这些方括号的意思(有a question有类似的问题,但没有得到任何答复)。

以下是构建和 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 在收到信号(中断或终止)时调用(或者如果程序正常终止)。此配置文件是在中断后获得的。

最佳答案

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

我的配置文件中不再有[evm-specifiation-miner](郑重声明,最重要的功能甚至都不是来 self 自己的包,所以这比它们没有更奇怪之前出现)。

关于go - pprof(对于 golang)不显示我的包的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45309074/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com