【发布时间】:2022-01-14 08:29:17
【问题描述】:
go tool pprof 有一个-call_tree 选项,根据-help,应该“创建一个上下文相关的调用树”。但是,CPU 配置文件上的pprof -tree 在有和没有这个选项的情况下都会给我完全相同的输出。它看起来像这样(一个代表节点):
flat flat% sum% cum cum% calls calls% + context
----------------------------------------------------------+-------------
0.07s 35.00% | google.golang.org/grpc/internal/transport.(*http2Server).operateHeaders
0.04s 20.00% | golang.org/x/net/http2.(*Framer).readMetaFrame
0.02s 10.00% | github.com/Shopify/sarama.(*FetchResponse).decode
0.06s 0.79% 51.18% 0.20s 2.63% | runtime.mapassign_faststr
0.05s 25.00% | runtime.newobject (inline)
0.03s 15.00% | aeshashbody
0.03s 15.00% | runtime.mallocgc
这显然不是一棵树,尤其是因为它显示了在 HTTP/2 下的 Sarama——从 Kafka 消费(通过 Sarama)和提供 HTTP/2 是这个过程同时执行的两个独立的事情。
为什么-call_tree 不影响-tree 的输出?一般来说,-call_tree 是做什么的?
额外积分
我上面显示的输出节点的确切含义是什么?这是否意味着包含mapassign_faststr 的样本中有35% 也包含operateHeaders,而10% 包含decode?下面的几行如mallocgc呢?
我可以阅读哪些文件来回答上述问题?
【问题讨论】: