火焰图使用指导

总结摘要
火焰图使用指导

学习教程

如何读懂火焰图?

https://www.ruanyifeng.com/blog/2017/09/flame-graph.html

https://juejin.cn/post/6844903498149003272

性能调优利器:火焰图

https://www.infoq.cn/article/a8kmnxdhbwmzxzsytlga

Java性能分析工具Async-Profiler

https://juejin.cn/post/7283699382419243066

【工具】Perf性能分析工具火焰图生成

https://blog.csdn.net/shankezh/article/details/124706430

perf生成火焰图(无敌总结)

https://www.cnblogs.com/asver/p/13895779.html

差分火焰图,让你的代码优化验证事半功倍

https://juejin.cn/post/7249288285876666425

arthas profiler

https://arthas.aliyun.com/doc/profiler.html

async-profiler

https://github.com/async-profiler/async-profiler

IDEA的火焰图简单使用

https://blog.csdn.net/xiaolixi199311/article/details/131714075

idea 启用火焰图功能

https://juejin.cn/post/6844903805423730696

用 perf 和火焰图做 mysql 性能调优

https://www.modb.pro/db/58271

性能分析工具perf & 火焰图使用指引

https://zhuanlan.zhihu.com/p/665758820

实践

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## 简单使用案例一——Linux

## 安装 perf
yum install perf.x86_64 -y

## 输出 perf.data
perf record -F 99 -p 3890 -g -- sleep 30

## 转换成out.perf文件
perf script -i perf.data > out.perf

## 安装 FlameGraph
## git --depth=1 clone https://github.com/brendangregg/FlameGraph.git

## 利用工具转换为out.folded文件
FlameGraph/stackcollapse-perf.pl out.perf  > out.floded
 
#转换为svg文件
FlameGraph/flamegraph.pl out.floded > out.svg
 

## 简单使用案例二——Java Async-Profiler

## 查询 pid,当前使用 7673
jps

## 启动,输出到 flamegraph.html
./bin/asprof -d 30 -f ./flamegraph.html  7673
## 停止
./bin/asprof stop  7673

问题记录
抛出异常 `Receive error - Could not open Flight Recorder output file #614`

问题原因
JVM 进程无当前目录的写权限。

解决方案
赋予 JVM 进程用户对输出文件目录的写权限。
使用 JVM 进程用户执行 ./bin/asprof 命令。

参考资料
Receive error - Could not open Flight Recorder output file #614
https://github.com/async-profiler/async-profiler/issues/614


## 简单使用案例三——Java Async-Profiler
profiler start
profiler getSamples
profiler status
profiler stop --format flamegraph --file /home/xxx/temp/arthas-profiler-result.html


## 简单使用案例四——IDEA
IDEA 中右键启动项目或执行 UT 时选择“Profile 'xxx' with 'IntelliJ Profiler'”。

END