我最近开始使用GoLang,并尝试将其与Redis集成。 因此我使用了radix库来执行此操作,尽管我的程序有时会卡住,而且我无法弄清是什么原因导致了卡住。 我尝试使用pprof对其进行更好的分析,但没有得到任何可以确定造成此问题的原因的结果。
我几乎有100%的CPU用在runtime.gopark上:
Type: goroutine
Showing nodes accounting for 110, 100% of 110 total
flat flat% sum% ■■■ ■■■%
108 98.18% 98.18% 108 98.18% runtime.gopark
1 0.91% 99.09% 1 0.91% runtime.notetsleepg
1 0.91% 100% 1 0.91% runtime/pprof.writeRuntimeProfile
当我将pprof与配置文件一起使用时,我也会得到100%的花费在runtime.usleep上
Duration: 10s, Total samples = 10ms ( 0.1%)
Showing nodes accounting for 10ms, 100% of 10ms total
flat flat% sum% ■■■ ■■■%
10ms 100% 100% 10ms 100% runtime.usleep
0 0% 100% 10ms 100% runtime.mstart
0 0% 100% 10ms 100% runtime.mstart1
0 0% 100% 10ms 100% runtime.sysmon
pprof互斥锁和块不返回任何内容
这是堆输出:
File: gw
Type: inuse_space
Time: Jul 7, 2019 at 10:23pm (UTC)
Showing nodes accounting for 5370.73kB, 100% of 5370.73kB total
----------------------------------------------------------±------------
flat flat% sum% ■■■ ■■■% calls calls% + context
----------------------------------------------------------±------------
1028kB 50.00% | bufio.NewWriter
1028kB 50.00% | github.com/valyala/fasthttp.acquireWriter
2056.01kB 38.28% 38.28% 2056.01kB 38.28% | bufio.NewWriterSize
----------------------------------------------------------±------------
1778.29kB 100% | compress/flate.NewWriter
1195.29kB 22.26% 60.54% 1778.29kB 33.11% | compress/flate.(*compressor).init
583.01kB 32.78% | compress/flate.newDeflateFast
----------------------------------------------------------±------------
583.01kB 100% | compress/flate.(*compressor).init
583.01kB 10.86% 71.39% 583.01kB 10.86% | compress/flate.newDeflateFast
----------------------------------------------------------±------------
....
我还尝试查看redis是否是问题所在,因此我创建了一个客户端,调用它以查看它仍然可用,并且似乎运行良好
有什么建议可以更好地对其进行分析吗?