golang tool pprof not working properly – same broken output regardless of profiling target

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

golang tool pprof not working properly - same broken output regardless of profiling target

问题

我之前使用pprof工具没有问题,它的表现非常好 - 现在无论我如何进行分析,都会看到以下的输出:

golang tool pprof not working properly – same broken output regardless of profiling target

在这个例子中,被分析的应用程序可能有40多个函数调用,而更复杂的应用程序也会产生类似的调用图,无论是CPU还是内存分析。

我尝试分析的应用程序都是Web应用程序,我每次分析一分钟,并使用wrk生成200,000,000+的请求,所有请求都返回数据和2xx响应。

pprof突然在几天前停止工作,我在尝试解决这个问题时最近升级到了El Capitan,但结果是一样的。

注意:这不仅仅是调用图 - 调用list或top命令也会产生类似贫瘠的结果,但应用程序本身工作正常:

  1. (pprof) top
  2. 269.97kB of 269.97kB total ( 100%)
  3. flat flat% sum% cum cum%
  4. 269.97kB 100% 100% 269.97kB 100%
  5. (pprof)

我使用的是以下包:"github.com/davecheney/profile",使用的是go v1.5.1

为了清楚起见,这是我生成分析报告的步骤:

我将上述包导入到main.go中,并将以下代码放在main函数的顶部:

  1. defer profile.Start(profile.MemProfile).Stop()

然后构建二进制文件并运行它:

  1. go build -o orig /Users/danielwall/www/netlistener/application/adrequest.go /Users/danielwall/www/netlistener/application/cookie.go /Users/danielwall/www/netlistener/application/header.go /Users/danielwall/www/netlistener/application/lex.go /Users/danielwall/www/netlistener/application/main.go /Users/danielwall/www/netlistener/application/publisher_ids.go /Users/danielwall/www/netlistener/application/request.go /Users/danielwall/www/netlistener/application/response.go /Users/danielwall/www/netlistener/application/server.go /Users/danielwall/www/netlistener/application/sniff.go /Users/danielwall/www/netlistener/application/status.go /Users/danielwall/www/netlistener/application/transfer.go
  2. ./orig

然后我会看到如下输出:

  1. 2015/11/16 11:39:49 profile: memory profiling enabled, /var/folders/26/2sj70_sn72l_93j7tf6r07gr0000gn/T/profile614358295/mem.pprof

然后我从另一个终端操作应用程序:

  1. wrk -d60 -c10 -H "X-Device: desktop" -H "X-Country-Code: GB" "http://localhost:8189/app?id=111&schema=xml2&ad_type=auto&url=http://test.com/&category=bob"
  2. Running 1m test @ http://localhost:8189/app?id=111&schema=xml2&ad_type=auto&url=http://test.com/&category=bob
  3. 2 threads and 10 connections
  4. Thread Stats Avg Stdev Max +/- Stdev
  5. Latency 414.09us 0.92ms 55.36ms 95.66%
  6. Req/Sec 17.57k 3.19k 22.59k 76.00%
  7. 2097764 requests in 1.00m, 684.20MB read
  8. Requests/sec: 34958.03
  9. Transfer/sec: 11.40MB

60秒后,我回去检查我的分析报告:

  1. ^C2015/11/16 12:05:20 profile: caught interrupt, stopping profiles
  2. go tool pprof /var/folders/26/2sj70_sn72l_93j7tf6r07gr0000gn/T/profile614358295/mem.pprof

有什么想法可能会发生这种情况,或者我可以从哪里开始进行故障排除/解决?

欢迎任何帮助和建议。

英文:

I've previously used the pprof tool without issue and it worked great - now I see output like the following no matter what I profile:

golang tool pprof not working properly – same broken output regardless of profiling target

the application being profiled in this example probably makes 40+ function calls and even more complex apps are producing similar callgraphs for both cpu and memprofiling.

The apps Im trying to profile are all web applications, I am profiling them for one minute at a time and using wrk to generate 200,000,000+ requests = all returning data and a 2xx response

pprof suddenly stopped working a few days ago running osx yosemite - in an attempt to resolve the issue I recently upgraded to el capitan but result is the same.

Note: this is not just call graphs - calling list or top command produce similarly barren results but the apps themselves work fine:

  1. (pprof) top
  2. 269.97kB of 269.97kB total ( 100%)
  3. flat flat% sum% cum cum%
  4. 269.97kB 100% 100% 269.97kB 100%
  5. (pprof)

I am using the following package: "github.com/davecheney/profile" with go v1.5.1

For clarity, here's what I'm doing to generate the profiles::

I import the above package into main.go and place the following at the top of my main func:

  1. defer profile.Start(profile.MemProfile).Stop()

I then build the binary and run it:

  1. go build -o orig /Users/danielwall/www/netlistener/application/adrequest.go /Users/danielwall/www/netlistener/application/cookie.go /Users/danielwall/www/netlistener/application/header.go /Users/danielwall/www/netlistener/application/lex.go /Users/danielwall/www/netlistener/application/main.go /Users/danielwall/www/netlistener/application/publisher_ids.go /Users/danielwall/www/netlistener/application/request.go /Users/danielwall/www/netlistener/application/response.go /Users/danielwall/www/netlistener/application/server.go /Users/danielwall/www/netlistener/application/sniff.go /Users/danielwall/www/netlistener/application/status.go /Users/danielwall/www/netlistener/application/transfer.go
  2. ./orig

I then see output like this:

  1. 2015/11/16 11:39:49 profile: memory profiling enabled, /var/folders/26/2sj70_sn72l_93j7tf6r07gr0000gn/T/profile614358295/mem.pprof

Now I work the app from another terminal :

  1. wrk -d60 -c10 -H "X-Device: desktop" -H "X-Country-Code: GB" "http://localhost:8189/app?id=111&schema=xml2&ad_type=auto&url=http://test.com/&category=bob"
  2. Running 1m test @ http://localhost:8189/app?id=111&schema=xml2&ad_type=auto&url=http://test.com/&category=bob
  3. 2 threads and 10 connections
  4. Thread Stats Avg Stdev Max +/- Stdev
  5. Latency 414.09us 0.92ms 55.36ms 95.66%
  6. Req/Sec 17.57k 3.19k 22.59k 76.00%
  7. 2097764 requests in 1.00m, 684.20MB read
  8. Requests/sec: 34958.03
  9. Transfer/sec: 11.40MB

After 60 seconds, I go back to check my profile:

  1. ^C2015/11/16 12:05:20 profile: caught interrupt, stopping profiles
  2. go tool pprof /var/folders/26/2sj70_sn72l_93j7tf6r07gr0000gn/T/profile614358295/mem.pprof

Any ideas what might be happening here or where I could start with trouble shooting/solving this?

Any help suggestions welcome.

答案1

得分: 10

您的go tool pprof调用缺少二进制文件本身。请按以下方式调用:

  1. go tool pprof ./orig /path/to/profile.pprof
英文:

Your go tool pprof call is missing the binary itself. Call it as

  1. go tool pprof ./orig /path/to/profile.pprof

huangapple
  • 本文由 发表于 2015年11月16日 21:17:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/33736363.html
匿名

发表评论

匿名网友

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

确定