dtzh131555
2015-11-12 20:05
浏览 78
已采纳

Golang分析Appengine测试

I appear to have a memory leak related to receiving large files and sending them to GCS. Trying to use pprof to profile memory usage for my appengine code. My tests use appengine/aetest and I can output the memory profile, but the results don't seem to show me anything useful.

First I made a benchmark. It is a very slow operation, so it only runs once.

$ 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

None of my function calls appear and this 0.5 MB figure is obviously incorrect (I am opening a 12 MB file and uploading it). How do I get the real memory profile?

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

图片转代码服务由CSDN问答提供 功能建议

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

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

  $ goapp test ./cloudstore -run = none -bench =。  -memprofile = cloud.prof 
BenchmarkLargeFile 1 54124706398 ns / op 
 
 $ go工具pprof --text cloudstore.test cloud.prof 
为1-in-524288采样率调整堆配置文件
总计: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版本
go版本go1.3.1 linux / 386 
 $ goapp版本
go版本go1.4.2(appengine-1.9  .25)linux / 386 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongqiang5932 2015-11-12 20:19
    已采纳

    Dug deeper into the testing flags and I found the answer. I needed memprofilerate=1 and alloc_space

    $ goapp test ./cloudstore -memprofilerate=1 -run=none -bench=. -memprofile=cloud.prof
    $ go tool pprof --text --alloc_space cloudstore.test cloud.prof
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题