标签: pprof

无法使用go工具pprof与现有服务器

我有一个现有的http服务器,我想分析.我已经包含_ "net/http/pprof"了我的导入,并且我已经运行了http服务器:

router := createRouter()
server := &http.Server {
    Addr:           ":8080",
    Handler:        router,
    ReadTimeout:    15*time.Second,
    WriteTimeout:   15*time.Second,
//  MaxHeaderBytes: 4096,
}

log.Fatal(server.ListenAndServe())
Run Code Online (Sandbox Code Playgroud)

当我试图访问http:// localhost:8080/debug/pprof /我得到404 page not found.

这是我go tool pprof在本地机器上使用时得到的:

userver@userver:~/Desktop/gotest$ go tool pprof http://192.168.0.27:8080/
Use of uninitialized value $prefix in concatenation (.) or string at /usr/lib/go/pkg/tool/linux_amd64/pprof line 3019.
Read http://192.168.0.27:8080/pprof/symbol
Failed to get the number of symbols from http://192.168.0.27:8080/pprof/symbol

userver@userver:~/Desktop/gotest$ go tool pprof http://localhost:8080/debug/pprof/profile
Read http://localhost:8080/debug/pprof/symbol
Failed to get the …
Run Code Online (Sandbox Code Playgroud)

go pprof gorilla

13
推荐指数
3
解决办法
5208
查看次数

如何使用pprof工具分析基准测试?

我想描述我生成的基准测试go test -c,但是go tool pprof需要一个通常在main函数中生成的配置文件,如下所示:

func main() {
    flag.Parse()
    if *cpuprofile != "" {
        f, err := os.Create(*cpuprofile)
        if err != nil {
            log.Fatal(err)
        }
        pprof.StartCPUProfile(f)
        defer pprof.StopCPUProfile()
    }
Run Code Online (Sandbox Code Playgroud)

如何在我的基准测试中创建配置文件?

benchmarking profiling go pprof

11
推荐指数
1
解决办法
7737
查看次数

Golang:什么是etext?

我已经开始介绍我的一些Go1.2代码,而顶级项目总是名为'etext'.我已经四处搜索但除了它可能与Go例程中的调用深度有关外,找不到有关它的更多信息.但是,我没有使用任何Go例程,'etext'仍占用总执行时间的75%或更多.

(pprof) top20 
Total: 171 samples
    128  74.9%  74.9%      128  74.9% etext
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释这是什么以及是否有任何方法可以减少影响?

linux profiling go pprof

10
推荐指数
1
解决办法
704
查看次数

如何优化在runtime.osyield和runtime.usleep中花费最多时间的golang程序

我一直在努力优化分析社交图数据的代码(有很多帮助来自https://blog.golang.org/profiling-go-programs),我已经成功地重做了很多慢速代码.

所有数据首先从db加载到内存中,并从那里进行数据分析显示CPU限制(最大内存消耗<10MB,CPU1 @ 100%)

但是现在我程序的大部分时间似乎都在runtime.osyield和runtime.usleep中.有什么方法可以防止这种情况发生?

我已经设置了GOMAXPROCS = 1,并且代码不会产生任何goroutine(除了golang库可能调用的内容).

这是我从pprof输出的top10

(pprof) top10
62550ms of 72360ms total (86.44%)
Dropped 208 nodes (cum <= 361.80ms)
Showing top 10 nodes out of 77 (cum >= 1040ms)
      flat  flat%   sum%        cum   cum%
   20760ms 28.69% 28.69%    20850ms 28.81%  runtime.osyield
   14070ms 19.44% 48.13%    14080ms 19.46%  runtime.usleep
   11740ms 16.22% 64.36%    23100ms 31.92%  _/C_/code/sc_proto/cloudgraph.(*Graph).LeafProb
    6170ms  8.53% 72.89%     6170ms  8.53%  runtime.memmove
    4740ms  6.55% 79.44%    10660ms 14.73%  runtime.typedslicecopy
    2040ms  2.82% 82.26%     2040ms  2.82%  _/C_/code/sc_proto.mAvg
     890ms  1.23% 83.49%     1590ms  2.20% …
Run Code Online (Sandbox Code Playgroud)

optimization go pprof

10
推荐指数
1
解决办法
4832
查看次数

如何在Go程序中使用pprof

如何在Go程序中使用pprof?

有一个名为net/http/pprof的Go包,但我无法使用它.

该文件说go tool pprof http://localhost:6060/debug/pprof/heap,这是行不通的.

而且,以下_是什么意思?

import _ "net/http/pprof"

go google-perftools pprof

7
推荐指数
1
解决办法
1万
查看次数

gperftools如何在引擎盖下工作?

我正在寻找一个关于gperftools如何工作的简单解释.到目前为止,这是我所学到的:

  • 它运行一个世界各地的采样器.换句话说,它会定期停止正在分析的程序以收集信息.
  • Golang的pprof库使用下面的gperftools.

除了一般概述,以下是我想回答的一些具体问题:

  • gperftools是" 基于事件的分析器 "还是" 仪器分析器 ".据我所知,这些分析器修改程序运行的方式并通过这些修改收集样本
  • 在操作系统的"级别"中,gperftools的配置文件是什么?它是否像SystemTapperf一样描述核心?
  • gperftools可以安全地在高流量的生产服务器上运行吗?

我问这个问题来推断在Go服务器上使用pprof引入的开销.

google-perftools gperftools pprof

7
推荐指数
1
解决办法
773
查看次数

如何解释pprof输出?

我正在尝试分析一个用go写的应用程序,它显然使用了大约256个虚拟内存(使用后检查ps aux).我正在尝试使用pprof包,看看哪些函数分配/消耗了大部分内存,但结果对我来说毫无意义.pprof top似乎只列出运行时函数.有人可以帮我理解这些数据吗?

ps aux |grep android
root      4584  3.4  0.1 500244 29536 pts/1    Sl+  17:21   0:38 ./android -logtostderr
Run Code Online (Sandbox Code Playgroud)

go tool pprof http:// localhost:6060/debug/pprof/heap

/pprof.localhost:6060.inuse_objects.inuse_space.008.pb.gz
Entering interactive mode (type "help" for commands)
(pprof) top
512.19kB of 512.19kB total (  100%)
Dropped 19 nodes (cum <= 2.56kB)
      flat  flat%   sum%        cum   cum%
  512.19kB   100%   100%   512.19kB   100%  runtime.malg
         0     0%   100%   512.19kB   100%  runtime.mcommoninit
         0     0%   100%   512.19kB   100%  runtime.mpreinit
         0     0%   100%   512.19kB   100% …
Run Code Online (Sandbox Code Playgroud)

performance go pprof heap-profiling

7
推荐指数
1
解决办法
7014
查看次数

Go(lang):如何使用PPROF堆配置文件来查找内存泄漏?

我正在尝试使用pprof来验证内存泄漏.

可以解释如何读取您在以下位置找到的堆配置文件: http://localhost:6060/debug/pprof/heap?debug=1

此外,通过web在启动go tool pprof http://localhost:6060/debug/pprof/heap它之后键入命令产生一个空的.svg文件是正常的吗?

非常感谢

memory-leaks go pprof heap-profiling

6
推荐指数
1
解决办法
6354
查看次数

golang tool pprof无法正常工作 - 无论性能分析目标如何,都会出现相同的断开输出

我之前使用过pprof工具没有问题,它工作得很好 - 现在我看到的输出如下,无论我简介:

pprof的输出

在这个例子中被分析的应用程序可能会进行40多个函数调用,甚至更复杂的应用程序也会为cpu和memprofiling生成类似的调用图.

我试图分析的应用程序都是Web应用程序,我一次分析它们一分钟并使用wrk生成200,000,000多个请求=所有返回数据和2xx响应

pprof几天前突然停止运行osx yosemite - 试图解决我最近升级到el capitan的问题,但结果是一样的.

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

    (pprof) top
269.97kB of 269.97kB total (  100%)
      flat  flat%   sum%        cum   cum%
  269.97kB   100%   100%   269.97kB   100%  
(pprof) 
Run Code Online (Sandbox Code Playgroud)

我正在使用以下软件包:"github.com/davecheney/profile"和go v1.5.1

为清楚起见,这是我正在做的生成配置文件::

我将上面的包导入main.go并将以下内容放在我的主函数的顶部:

defer profile.Start(profile.MemProfile).Stop()
Run Code Online (Sandbox Code Playgroud)

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

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

./orig
Run Code Online (Sandbox Code Playgroud)

然后我看到这样的输出:

2015/11/16 11:39:49 profile: memory profiling enabled, /var/folders/26/2sj70_sn72l_93j7tf6r07gr0000gn/T/profile614358295/mem.pprof
Run Code Online (Sandbox Code Playgroud)

现在我从另一个终端处理应用程序:

    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"
Running 1m test @ http://localhost:8189/app?id=111&schema=xml2&ad_type=auto&url=http://test.com/&category=bob …
Run Code Online (Sandbox Code Playgroud)

macos go pprof

6
推荐指数
1
解决办法
998
查看次数

go 应用程序的 pprof CPU 配置文件未显示任何示例

我正在使用 pprof 分析 Go 应用程序。

该应用程序使用了大约 4-10% 的 CPU,并让它运行一小段时间,生成大约 6-11kb 的配置文件。这对我来说意味着它应该能够对某些活动进行采样。

然而,当我查看结果时,我看到以下内容:

$ go tool pprof --text bigproc
1.77s of 1.77s total (  100%)
      flat  flat%   sum%        cum   cum%
     1.77s   100%   100%      1.77s   100%
$
Run Code Online (Sandbox Code Playgroud)

有趣的信息似乎缺失了。可能出什么问题了?

这是在 Linux 上,使用 google-perftools 的 go 版本 1.6.1 和 pprof 版本 2.2.1(如果重要的话)。

performance profiling go pprof

6
推荐指数
1
解决办法
5280
查看次数