pprof新增的火焰图实现

简介: pprof新增的火焰图实现

最近用pprof,发现新增了一个选项

微信截图_20230801185233.png

微信截图_20230801185251.png

微信截图_20230801185300.png

应路径为 flamegraph2


追本溯源,这个改动是在2022年11月底被引入(注释了"实验性的"),随2023年2月初的Go 1.20版本发布。 不过查看了 Go 1.20 Release Notes,好像并没有提及此处改动。

微信截图_20230801185315.png

这里用的库是 github.com/google/ppro…,查看了这个项目的改动

微信截图_20230801185508.png

是在2022年8月中旬,commit信息为:

Added alternative flamegraph implementation that can show callers. (#716)
Add an experimental flame-graph implementation. It can be selected in
pprof's web interface using the new "Flame (experimental)" menu entry.
At some point this new implementation may become the default.
The new view is similar to flame-graph view. But it can show caller
information as well. This should allow it to satisfy many users of
Graph and Peek views as well.
Let's illustrate with an example. Suppose we have profile data that
consists of the following stacks:

1000 main -> foo -> malloc 2000 main -> bar -> malloc

When main is selected, both the old and new views show:

[-------------------3000 main---------------------] [---1000 foo-----] [----------2000 bar------------] [---1000 malloc--] [----------2000 malloc---------]

But suppose now the user selects the right-most malloc slot.
The old view will show just the path leading to that malloc:

[----------2000 main-----------] [----------2000 bar------------] [----------2000 malloc---------]

The new view will however show a flame-graph view that grows
upwards that displays the call stacks leading to malloc:

[---1000 main----] [----------2000 main-----------] [---1000 foo-----] [----------2000 bar------------] [-------------------3000 malloc-------------------]

This caller display is useful when trying to determine expensive
callers of function.
A list of important differences between the new view and flame graphs:
New view pros:
1.  Callers are shown, e.g., all paths leading to malloc.
2.  Shows self-cost clearly with a different saturation.
3.  Font size is adjusted to fit more text into boxes.
4.  Highlighting on hover shows other occurrences of a function.
5.  Search works more like other views.
6.  Pivot changes are reflected in browser history (so back and forward
    buttons can be used to navigate between different selections).
7.  Allows eventual removal of the D3 dependency, which may make
    integrations into various environments easier.
8.  Colors provide higher contrast between foreground and background.
New view cons:
1.  There are small differences in how things look and feel.
2.  Color-scheme is very different.
3.  Change triggered by selecting a new entry is not animated.

以下内容来自ChatGPT:

在这个提交中,添加了一个实验性的火焰图(flame graph)实现。可以通过pprof的Web界面选择新的"Flame (experimental)"菜单项来查看。在某个时刻,这个新实现可能会成为默认选项。

这个新视图类似于火焰图视图,但是它可以显示调用者信息。这样可以满足许多使用Graph和Peek视图的用户的需求。

让我们通过一个例子来说明。假设我们有以下堆栈的性能数据:

1000  main -> foo -> malloc
2000  main -> bar -> malloc

当选择main时,旧视图和新视图都会显示:

[-------------------3000 main---------------------]
[---1000 foo-----] [----------2000 bar------------]
[---1000 malloc--] [----------2000 malloc---------]

但是,假设现在用户选择最右边的malloc槽。旧视图将只显示通往该malloc的路径:

[----------2000 main-----------]
[----------2000 bar------------]
[----------2000 malloc---------]

然而,新视图将显示一个火焰图视图,从下往上展示通往malloc的调用堆栈:

[---1000 main----] [----------2000 main-----------]
[---1000 foo-----] [----------2000 bar------------]
[-------------------3000 malloc-------------------]

这个调用者显示在确定函数的开销较大时非常有用。

新视图和火焰图之间的一些重要区别如下:

新视图的优势:

  1. 显示调用者,例如,所有通往malloc的路径。
  2. 使用不同的颜色饱和度清楚地显示自身开销。
  3. 字体大小调整以在方框中显示更多文本。
  4. 悬停时的高亮显示显示函数的其他出现。
  5. 搜索功能的工作方式更像其他视图。
  6. 值轴更改会在浏览器历史中反映出来(因此可以使用前进和后退按钮在不同的选择之间导航)。
  7. 允许最终删除D3依赖项,这可能使集成到各种环境中变得更容易。
  8. 颜色提供前景和背景之间更高的对比度。

新视图的缺点:

  1. 外观和感觉上有些微小的差异。
  2. 颜色方案有很大的不同。
  3. 选择新条目触发的更改没有动画效果。


目录
相关文章
|
3月前
|
Arthas Java 测试技术
Arthas本身并没有提供直接让进程结束时自动生成火焰图的配置
【2月更文挑战第31天】Arthas本身并没有提供直接让进程结束时自动生成火焰图的配置
101 2
|
Linux
如何看懂火焰图
如何看懂火焰图
906 0
如何看懂火焰图
|
14天前
|
数据可视化 前端开发
可视化图表与源代码显示的动态调整
【8月更文挑战第6天】本篇文章通过一个前端图表示例由浅入深,从基本图表显示再到页面源代码的显示到最后实现通过拖动一个可调整大小的分隔符,使用户可以动态地调整图表显示区域和源代码显示区域的大小。全文注释标注,小白也可上手尝试
33 1
可视化图表与源代码显示的动态调整
|
21天前
|
Serverless 文件存储 对象存储
函数计算操作报错合集之如何处理安装了ControlNet但无法加载出预览图并报错
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。
函数计算操作报错合集之如何处理安装了ControlNet但无法加载出预览图并报错
|
3月前
|
JavaScript
性能工具之 FlameGraph 火焰图
其实很多类似 perf 的工具都能生成火焰图,像 systemtap/dtrace 之类的 并且这个思路,现在在 js 优化、代码优化等各方面都有具体的应用了 至于怎么理解? 简单点说,就是看谁又平又宽
105 7
性能工具之 FlameGraph 火焰图
|
8月前
|
Ubuntu
代码性能展现 火焰图
代码性能展现 火焰图
55 0
|
数据可视化 Python
基础 | Pyecharts 动态时序图(时间线轮播图各参数配置)
基础 | Pyecharts 动态时序图(时间线轮播图各参数配置)
|
Ubuntu
perf + 火焰图分析软件性能
perf + 火焰图分析软件性能
130 0
|
数据采集 数据可视化
|
uml C++
VS工具使用——代码图
引用: 《论语·卫灵公》中,子贡问为仁。子曰:“工欲善其事,必先利其器。居是邦也,事其大夫之贤者,友其士之仁者。”大概的意思是:子贡问怎样修养仁德。孔子说:“工匠要做好工作,必须先磨快工具。住在一个国家,要侍奉大夫中的贤人,与士人中的仁人交朋友。” 今天我将用我的工具——VS2013为大家介绍一下我对“工欲善其事,必先利其器”的理解。
115 0