【问题标题】:Golang profiling appengine testsGolang 分析应用引擎测试
【发布时间】:2015-11-13 04:19:22
【问题描述】:

我似乎有与接收大文件并将它们发送到 GCS 相关的内存泄漏。尝试使用 pprof 来分析我的 appengine 代码的内存使用情况。我的测试使用 appengine/aetest,我可以输出内存配置文件,但结果似乎没有显示任何有用的信息。

首先我做了一个基准测试。这是一个非常慢的操作,所以它只运行一次。

$ goapp test ./cloudstore -run=none -bench=. -memprofile=cloud.prof
BenchmarkLargeFile      1        54124706398 ns/op

$ go tool pprof --text cloudstore.test cloud.prof 
Adjusting heap profiles for 1-in-524288 sampling rate
Total: 0.5 MB
     0.5 100.0% 100.0%      0.5 100.0% runtime.newG
     0.0   0.0% 100.0%      0.5 100.0% allocg
     0.0   0.0% 100.0%      0.5 100.0% mcommoninit
     0.0   0.0% 100.0%      0.5 100.0% runtime.malg
     0.0   0.0% 100.0%      0.5 100.0% runtime.mpreinit
     0.0   0.0% 100.0%      0.5 100.0% runtime.rt0_go
     0.0   0.0% 100.0%      0.5 100.0% runtime.schedinit

我的函数调用都没有出现,这个 0.5 MB 的数字显然不正确(我正在打开一个 12 MB 的文件并上传它)。如何获取真实的内存配置文件?

$ go version
go version go1.3.1 linux/386
$ goapp version
go version go1.4.2 (appengine-1.9.25) linux/386

【问题讨论】:

    标签: google-app-engine go pprof


    【解决方案1】:

    深入研究测试标志,我找到了答案。我需要 memprofilerate=1 和 alloc_space

    $ goapp test ./cloudstore -memprofilerate=1 -run=none -bench=. -memprofile=cloud.prof
    $ go tool pprof --text --alloc_space cloudstore.test cloud.prof
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 2015-11-23
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多