1. async-profiler是什么?
async-profiler是一种低开销的Java采样分析器,不会受Safepoint偏差问题的影响。它具有专门为HotSpot设计的API,用于收集堆栈跟踪信息并跟踪内存分配。分析器可以与OpenJDK、Oracle JDK和其他基于HotSpot JVM的Java运行时一起使用。
async-profiler可以跟踪以下类型的事件:
CPU周期
硬件和软件性能计数器,例如缓存丢失、分支丢失、页错误、上下文切换等
Java堆中的分配
内容锁定尝试,包括Java对象监视器和可重入锁
总结接一下就是能够用来对Java项目进行调优通过分析上述的一些指标。从指标中找出项目中可能存在的优化点。
1.1 如何安装
直接从github的项目地址下载对应的平台的安装包。然后将其解压到目录中即可:

安装的过程即将安装包下载解压即可完成无需复杂的步骤。
1.2 如何使用
用如下命令查看使用帮助:
$ ./profiler.sh -h
Usage: ./profiler.sh [action] [options] <pid>
Actions:
start start profiling andreturn immediately
resume resume profiling without resetting collected data
stop stop profiling
dump dump collected data without stopping profiling session
check check if the specified profiling event is available
status print profiling status
meminfo print profiler memory stats
list list profiling