Arthas-Java 线上问题定位处理的终极利器-火焰图

前提

提前安装 Arthas

profiler 命令生成火焰图

原理使用 async-profiler 生成火焰图
profiler 命令支持生成应用热点的火焰图。本质上是通过不断的采样,然后把收集到的采样结果生成火焰图。
profiler 命令基本运行结构是 profiler action [actionArg]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0gKEfUp8-1616066736197)(http://10.152.160.36/server/index.php?s=/api/attachment/visitFile/sign/e4e8e6d0f58099e067e57e0ac998c491&showdoc=.jpg)]

查看所有支持的 action:

[arthas@9737]$ profiler actions
Supported Actions: [resume, dumpCollapsed, getSamples, start, list, execute, version, stop, load, dumpFlat, actions, dumpTraces, status]
[arthas@9737]$ 

查看版本:

[arthas@9737]$ profiler version
1.8.3
[arthas@9737]$ 

启动 profiler:

[arthas@9737]$ profiler start
Started [cpu] profiling
[arthas@9737]$ 

默认情况下,生成的是cpu的火焰图

获取已采集的 sample 的数量:
[arthas@9737]$  profiler getSamples
12
[arthas@9737]

查看 profiler 状态:
可以查看当前 profiler 在采样哪种 event 和采样时间。

[arthas@9737]$ profiler status
[perf] profiling is running for 166 seconds
[arthas@9737]$ 

停止 profiler 生成 svg 格式结果

[arthas@9737]$  profiler stop
OK
profiler output file: /root/arthas-output/20210318-190449.svg
[arthas@9737]$ 

通过浏览器查看 arthas-output 下面的 profiler 结果:
默认情况下,arthas 使用 8563 http端口,则可以打开: http://192.168.189.131:8563/arthas-output/ 目录下面的profiler 结果:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Ikckpaz4-1616066736209)(http://10.152.160.36/server/index.php?s=/api/attachment/visitFile/sign/6916c0acac813d1edcc241a52efacb7c&showdoc=.jpg)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LhtHEWw8-1616066736210)(http://10.152.160.36/server/index.php?s=/api/attachment/visitFile/sign/ad148243fe1ab5188722b9b4353681d5&showdoc=.jpg)]

profiler支持的events:
在不同的平台,不同的OS下面,支持的events各有不同

扫描二维码关注公众号,回复: 12748137 查看本文章
[arthas@9737]$ profiler list
Basic events:
  cpu
  alloc
  lock
  wall
  itimer
Java method calls:
  ClassName.methodName
Perf events:
  page-faults
  context-switches
  cycles
  instructions
  cache-references
  cache-misses
  branches
  branch-misses
  bus-cycles
  L1-dcache-load-misses
  LLC-load-misses
  dTLB-load-misses
  mem:breakpoint
  trace:tracepoint
[arthas@9737]$ 

猜你喜欢

转载自blog.csdn.net/qq_31555951/article/details/114988420
今日推荐