async-profiler 查看 jvm 支持的分析事件列表

tuk*_*tuk 1 java jvm async-profiler

我正在尝试查看 jvm 支持的分析事件列表。正如文档中提到的,我使用了list如下所示的命令 -

root@vrni-platform:/home/ubuntu/async-profiler-2.0-linux-x64# ./profiler.sh list 10208
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
Run Code Online (Sandbox Code Playgroud)

我在上面的输出中没有看到这个答案中提到的事件。但是,如果我按照该答案中提到的方式执行上述事件,它似乎就可以工作。

root@vrni-platform:/home/ubuntu/async-profiler-2.0-linux-x64# ./profiler.sh -e malloc -d 30 -f /tmp/flamegraph.html 10208
Profiling for 30 seconds
Done
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

有人可以告诉我如何查看 aysnc-profiler 支持的特定 jvm 的所有事件列表吗?如果list是正确的参数,profiler.sh那么为什么 malloc 等显示在所有事件列表下?

环境

ubuntu@vrni-platform:~/async-profiler-2.0-linux-x64# ./profiler.sh --version
Async-profiler 2.0 built on Mar 14 2021
Copyright 2016-2021 Andrei Pangin
Run Code Online (Sandbox Code Playgroud)
ubuntu@vrni-platform:~/async-profiler-2.0-linux-x64# uname -a
Linux vrni-platform 4.15.0-142-generic #146-Ubuntu SMP Tue Apr 13 01:11:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
ubuntu@vrni-platform:~/async-profiler-2.0-linux-x64$ java -version
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment Zulu11.48+22-SA (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.48+22-SA (build 11.0.11+9-LTS, mixed mode)
Run Code Online (Sandbox Code Playgroud)

apa*_*gin 5

malloc这不是一个单独的事件。这只是执行断点的一个示例。

async-profiler 在硬件断点的帮助下,可以跟踪对任何内存位置的访问。使用类似 perf 的硬件断点语法,您可以选择分析代码中任何给定地址的执行情况:

./profiler.sh -e mem:0x123450:x <pid>
Run Code Online (Sandbox Code Playgroud)

可以指定本机函数名称,而不是数字地址。malloc只是标准 C 库 (libc) 中函数的名称:

./profiler.sh -e mem:malloc:x <pid>
Run Code Online (Sandbox Code Playgroud)

And-e malloc是上述事件描述符的快捷方式。如果 async-profiler 发现给定的事件名称对应于某个本机函数,它会分析该函数的执行。

除了 之外malloc,您还可以分析任何其他函数。例如,

  • -e pthread_start查找谁启动了新线程(Java 线程和本机线程);
  • -e connect分析新的套接字连接;
  • -e JVM_GC查找 的呼叫者System.gc()
  • -e G1CollectedHeap::humongous_obj_allocate分析 G1 的巨大分配;
  • -e Deoptimization::uncommon_trap找到编译后的代码去优化的地方;

等等等等。JVM 中、标准类库中、libc 中都有数千个本机函数。显然,实际上不可能在 async-profiler 帮助中列出所有这些内容。