Arthas
是Alibaba开源的Java诊断工具,深受开发者喜好。html
Arthas 3.1.5版本带来下面全新的特性:java
火焰图的威名相信你们都有所耳闻,但可能由于使用比较复杂,因此望而止步。linux
在新版本的Arthas里集成了async-profiler,使用profiler
命令就能够很方便地生成火焰图,而且能够在浏览器里直接查看。git
profiler
命令基本运行结构是 profiler action [actionArg]
。下面介绍如何使用。github
$ profiler start
Started [cpu] profiling
复制代码
默认状况下,生成的是cpu的火焰图,即event为
cpu
。能够用--event
参数来指定。chrome
$ profiler getSamples
23
复制代码
$ profiler status
[cpu] profiling is running for 4 seconds
复制代码
能够查看当前profiler在采样哪一种event
和采样时间。浏览器
$ profiler stop
profiler output file: /tmp/demo/arthas-output/20191125-135546.svg
OK
复制代码
默认状况下,生成的结果保存到应用的工做目录
下的arthas-output
目录里。bash
默认状况下,arthas使用3658端口,则能够打开: http://localhost:3658/arthas-output/ 查看到arthas-output
目录下面的profiler结果:jvm
点击能够查看具体的结果:async
若是是chrome浏览器,可能须要屡次刷新。
标准的linux grep命令支持丰富的选项,能够很方便地定位结果的上下文等。
新版本的grep
命令支持更多标准的选项,下面是一些例子:
sysprop | grep java
sysprop | grep java -n
sysenv | grep -v JAVA
sysenv | grep -e "(?i)(JAVA|sun)" -m 3 -C 2
sysenv | grep JAVA -A2 -B3
thread | grep -m 10 -e "TIMED_WAITING|WAITING"
复制代码
感谢社区里 @qxo 的贡献。
默认状况下,Arthas的Telnet端口是3658,HTTP端口是8563,这个经常让用户迷惑。在新版本里,在3658端口同时支持Telnet/HTTP协议。
在浏览器里访问 http://localhost:3658/ 也能够访问到Web Console了。
在后续的版本里,考虑默认只侦听 3658端口,减小用户的配置项。
之前Arthas被诟病比较多的一个问题是,monitor/tt/trace等命令时间统计偏差大。由于之前只使用了一个int来保存时间,因此不精确。
在新版本里,改用一个高效的stack来保存数据,时间的准确度大大提高,欢迎你们反馈效果。
感谢社区里 @huangjIT 的贡献。
总之,3.1.5
版本的Arthas引入了开箱即用的Profiler/火焰图功能,欢迎你们使用反馈。
最后,Arthas 正在参加2019年度最受欢迎开源中国软件评选,急需你们宝贵的一票支持!!查看
投票后能够到 issue 里抽奖两本图书,github.com/alibaba/art… :