带有堆分析的 google-perftools/pprof 格式

发布于 2024-12-15 02:36:26 字数 852 浏览 1 评论 0原文

google-perftools 包中有一个 pprof 实用程序。它是将配置文件从 google-perftools cpuprofiler 和 heapprofiler 转换为漂亮图像的实用程序:如 https://github.com/gperftools/gperftools/tree/master/doc/pprof-test-big.gifhttps://github.com/gperftools/gperftools/tree/master /doc/heap-example1.png

pprof 输入文件的格式在此处针对 cpu 配置文件进行了描述:https://github.com/gperftools/gperftools/tree/master/doc /cpuprofile-fileformat.html

但是 svn 中没有描述 heap profile 输入文件的格式。

什么是“heapprofiling”格式以及如何从我的代码生成此类文件?我已经可以生成 cpuprofiler 格式,所以我感兴趣两种格式之间的区别。

There is a pprof utility in google-perftools package. It is utility to convert profile files from google-perftools cpuprofiler and heapprofiler into beautiful images: like https://github.com/gperftools/gperftools/tree/master/doc/pprof-test-big.gif and
https://github.com/gperftools/gperftools/tree/master/doc/heap-example1.png

The format of pprof's input file is described for cpu profiles here: https://github.com/gperftools/gperftools/tree/master/doc/cpuprofile-fileformat.html

but the format of heap profile input files is not described in the svn.

What is the "heapprofiling" format and how can I generate such file from my code? I already can generate cpuprofiler format, so I interested what are the difference between two formats.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼窥荷 2024-12-22 02:36:26

对于 cpu profiler 来说,格式似乎不是二进制的,而是文本的:

第一行:

 heap profile:   1:   2 [ 3:  4] @ heapprofile

正则表达式(不完整),

 (\d+): (\d+) \[(\d+): (\d+)\] @ ([^/]*)(/(\d+))?)?

其中

  • 1 & 2是“使用中的统计数据”;第一个数字是分配计数,第二个数字是字节计数
  • 3 & 4是“总分配统计数据”;第一个和第二个具有相同含义
  • heapprofile 是类型

然后配置文件本身包含很多行:

 1: 2 [ 3: 4] @ 0x00001 0x00002 0x00003

其中“1: 2”和“3: 4”与第一行中的含义相同;但仅从给定的调用站点分配; 0x00001 0x00002 是调用站点的调用堆栈。

然后是空行和“MAPPED_LIBRARIES:”。从下一行开始,接下来的内容非常类似于 /proc/pid/maps 的副本。

Seems the format is not binary as for cpu profiler, but textual:

First line:

 heap profile:   1:   2 [ 3:  4] @ heapprofile

Regex (not full)

 (\d+): (\d+) \[(\d+): (\d+)\] @ ([^/]*)(/(\d+))?)?

where

  • 1 & 2 is "in-use stats"; first number is count of allocations, second is byte count
  • 3 & 4 is "total allocated stats"; first and second with same meaning
  • heapprofile is the type

Then a profile itself follows in lot of lines:

 1: 2 [ 3: 4] @ 0x00001 0x00002 0x00003

where "1: 2" and "3: 4" is of the same meaning as in first line; but only malloced from given callsite; 0x00001 0x00002 is callstack of the callsite.

Then empty line and "MAPPED_LIBRARIES:". From the next line something very like copy of the /proc/pid/maps follows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文