Alibaba Arthas 3.1.5版本支持火焰图,快速定位应用热点

Arthas

Arthas是Alibaba开源的Java诊断工具,深受开发者喜好。html

Arthas 3.1.5版本带来下面全新的特性:java

  • 开箱即用的Profiler/火焰图功能
  • grep命令支持更丰富的选项
  • monitor/tt/trace等命令提供更精确的时间统计
  • telnet/http协议共用3658端口

Profiler/Frame Graph/火焰图

火焰图的威名相信你们都有所耳闻,但可能由于使用比较复杂,因此望而止步。linux

在新版本的Arthas里集成了async-profiler,使用profiler命令就能够很方便地生成火焰图,而且能够在浏览器里直接查看。git

profiler 命令基本运行结构是 profiler action [actionArg]。下面介绍如何使用。github

启动profiler

$ profiler start
Started [cpu] profiling
复制代码

默认状况下,生成的是cpu的火焰图,即event为cpu。能够用--event参数来指定。chrome

获取已采集的sample的数量

$ profiler getSamples
23
复制代码

查看profiler状态

$ profiler status
[cpu] profiling is running for 4 seconds
复制代码

能够查看当前profiler在采样哪一种event和采样时间。浏览器

生成svg格式结果

$ profiler stop
profiler output file: /tmp/demo/arthas-output/20191125-135546.svg
OK
复制代码

默认状况下,生成的结果保存到应用的工做目录下的arthas-output目录里。bash

经过浏览器查看arthas-output下面的profiler结果

默认状况下,arthas使用3658端口,则能够打开: http://localhost:3658/arthas-output/ 查看到arthas-output目录下面的profiler结果:jvm

点击能够查看具体的结果:async

若是是chrome浏览器,可能须要屡次刷新。

grep命令支持更丰富的选项

标准的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 的贡献。

telnet/http协议共用3658端口

默认状况下,Arthas的Telnet端口是3658,HTTP端口是8563,这个经常让用户迷惑。在新版本里,在3658端口同时支持Telnet/HTTP协议。

在浏览器里访问 http://localhost:3658/ 也能够访问到Web Console了。

在后续的版本里,考虑默认只侦听 3658端口,减小用户的配置项。

monitor/tt/trace等命令提供更精确的时间统计

之前Arthas被诟病比较多的一个问题是,monitor/tt/trace等命令时间统计偏差大。由于之前只使用了一个int来保存时间,因此不精确。

在新版本里,改用一个高效的stack来保存数据,时间的准确度大大提高,欢迎你们反馈效果。

感谢社区里 @huangjIT 的贡献。

总结

总之,3.1.5版本的Arthas引入了开箱即用的Profiler/火焰图功能,欢迎你们使用反馈。

最后,Arthas 正在参加2019年度最受欢迎开源中国软件评选,急需你们宝贵的一票支持!!查看

投票后能够到 issue 里抽奖两本图书,github.com/alibaba/art…

  • 《 OpenShift 在企业中的实践-PasS DevOps 微服务》
  • 《协同-数字化时代组织效率的本质》
相关文章
相关标签/搜索