使用FlameGraph火焰图分析JAVA应用性能

开源项目推荐

Pepper Metrics是我与同事开发的一个开源工具(github.com/zrbcool/pep…),其经过收集jedis/mybatis/httpservlet/dubbo/motan的运行性能统计,并暴露成prometheus等主流时序数据库兼容数据,经过grafana展现趋势。其插件化的架构也很是方便使用者扩展并集成其余开源组件。
请你们给个star,同时欢迎你们成为开发者提交PR一块儿完善项目。html

安装及使用

安装前提软件java

centos

yum install perf -y
yum install gcc -y
yum install gcc-c++
yum install cmake -y
复制代码

ubuntu

apt install linux-tools-generic
apt install linux-tools-common
复制代码

FlameGraph

# 参考 http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#Java
export JAVA_HOME=/root/jdk1.8.0_181
export PATH=$JAVA_HOME/bin:$PATH
git clone --depth=1 https://github.com/jrudolph/perf-map-agent
cd perf-map-agent
cmake .
make
bin/create-links-in /usr/bin

git clone https://github.com/brendangregg/FlameGraph.git
export FLAMEGRAPH_DIR=/root/git/FlameGraph
# jvm启动参数须要增长
-XX:+PreserveFramePointer

perf-java-flames 21322
export PERF_RECORD_SECONDS=45
复制代码

结果展现

svg格式的图片能够下钻,点击查看:linux

Docker内怎么办?

github.com/jvm-profili… blog.alicegoldfuss.com/making-flam… github.com/mboussaa/do… www.batey.info/docker-jvm-…c++

容器内如何分析?

请参考笔者的另外一篇文章Docker中使用FlameGraph分析JVM应用性能git

更多参考

https://www.meiwen.com.cn/subject/xafqkqtx.html
https://bugs.openjdk.java.net/browse/JDK-8068945
https://bugs.openjdk.java.net/browse/JDK-6515172
http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2014-December/016477.html
https://medium.com/netflix-techblog/java-in-flames-e763b3d32166
https://blog.codecentric.de/en/2017/09/jvm-fire-using-flame-graphs-analyse-performance/
https://github.com/jvm-profiling-tools/honest-profiler/wiki/How-to-Run
https://gperftools.github.io/gperftools/pprof-vsnprintf-big.gif
https://github.com/jvm-profiling-tools/perf-map-agent
http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#Java
http://www.brendangregg.com/blog/2014-06-12/java-flame-graphs.html
https://github.com/brendangregg/FlameGraph  
复制代码

做者其余文章

github.com/zrbcool/blo…github

微信订阅号

相关文章
相关标签/搜索