1 下載編譯async-profiler
git clone https://github.com/jvm-profiling-tools/async-profiler
cd async-profiler
make all
2 獲取java進程的pid
ps aux | grep product
/dir/to/async-profiler/profiler.sh -d 30 -f /tmp/flamegraph.svg {pid}
sh profiler.sh -d 30 -f /tmp/flamegraph.svg {pid}
3 采集數(shù)據(jù)生成火焰圖
-d:采集數(shù)據(jù)持續(xù)時間(秒)
-f:火焰圖存儲文件名
pid:要采集的進程pid
更多用法: [https://github.com/jvm-profiling-tools/async-profiler](https://github.com/jvm-profiling-tools/async-profiler)
4 打開瀏覽器查看火焰圖
高度表示調(diào)用棧的深度
寬度表示cpu采樣占比啥酱,越寬表示采樣越多观游,注意,寬度不代表時間占比兜叨,IO等待是體現(xiàn)不出來的
顏色是為了好看聂沙。