Arthas生成Kafka火焰图
2022-06-19 本文已影响0人
Alen_ab56
步骤:
1. 安装Arthas
wget https://github.com/alibaba/arthas/releases/download/arthas-all-3.5.4/arthas-bin.zip
mkdir -p arthas
unzip arthas-bin.zip -d arthas
2. attach目标程序
2.1 arthas
选择进程号
2.3 开始生成
profiler start
手动停止
profiler stop
火焰图svg文件会被存放到指定目录
接下来是解析环节,如何看出哪些行为占用的CPU较大

总的来说
1. 颜色本身没有什么意义
2. 纵向表示调用栈的深度
3. 横向表示消耗的时间
横向来看
由于横向表示消耗的时间,所以一个格子的宽度越大越说明其可能是瓶颈
纵向来看
由于纵向表示调用栈的深度,所以火焰的火苗尖部就是CPU正在执行的操作
综上
主要看那些比较宽大的火苗
特别是那些平头的火苗
上述是默认的CPU火焰图
我们还可以利用它来生成内存火焰图 $ profiler start --event alloc

更多使用说明参考:https://arthas.aliyun.com/doc/profiler.html
或者我们可以自己通过JVMTI机制来实现一把
本质上火焰图和其他jstack等工具的实现原理一样,并且要解决的问题都是分析线上运行中的程序的各种运行时情况,帮助我们排查一些问题故障