JITwatch是Java HotSpot JIT的日志分析器,我们可以通过它来了解Java HotSpot JIT的行为。本文主要讲它的安装,步骤如下:
(1)下载JITwatch的jar包:
wget https://adopt-openjdk.ci.cloudbees.com/job/jitwatch/jdk=JDK_1.7/ws/jitwatch-1.0.0-SNAPSHOT-JDK_1.7.tar.gz
这里下载的是JDK1.7版本的。解压即可得到jar包。
(2)获得JITwatch的依赖jar包:
wget https://github.com/AdoptOpenJDK/jitwatch/archive/master.zip
解压该文件,从lib目录下得到相关的jar包。
(3)把前面得到的所有jar包放在一个目录下:
(jitwatch.out是运行下面的命令生成的)
(4)运行下面的命令启动JITwatch:
java -cp /usr/lib/jvm/jdk1.7.0_67/lib:/usr/lib/jvm/jdk1.7.0_67/jre/lib/jfxrt.jar:jitwatch-1.0.0-SNAPSHOT.jar:slf4j-api-1.7.7.jar:hamcrest-core-1.3.jar:logback-classic-1.1.2.jar:logback-core-1.1.2.jar org.adoptopenjdk.jitwatch.launch.LaunchUI
JITwatch启动了:
启动命令分析:
/usr/lib/jvm/jdk1.7.0_67/lib:/usr/lib/jvm/jdk1.7.0_67/jre/lib/jfxrt.jar部分需要根据自己的环境设置。
org.adoptopenjdk.jitwatch.launch.LaunchUI可以通过分析JITwatch项目的launchUI.sh文件来获得:
#!/bin/sh
unamestr=`uname`
if [ "$JAVA_HOME" = ‘‘ ]; then
if [ "$unamestr" = ‘Darwin‘ ]; then
export JAVA_HOME=`/usr/libexec/java_home`
else
echo "JAVA_HOME has not been set."
exit 0;
fi
fi
# Requires the jar to be built using
# mvn package
# or
# ant jar
#
#
# You may need to set -Xmx (max heap) and -XX:MaxPermSize
# if your hotspot.log references a lot of classes
CLASSPATH=$CLASSPATH:lib/logback-classic-1.1.2.jar
CLASSPATH=$CLASSPATH:lib/logback-core-1.1.2.jar
CLASSPATH=$CLASSPATH:lib/slf4j-api-1.7.7.jar
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
CLASSPATH=$CLASSPATH:$JAVA_HOME/jre/lib/jfxrt.jar
CLASSPATH=$CLASSPATH:target/jitwatch-1.0.0-SNAPSHOT.jar
"$JAVA_HOME/bin/java" -Djava.library.path=$JAVA_HOME/lib/amd64 -cp "$CLASSPATH" [email protected]
org.adoptopenjdk.jitwatch.launch.LaunchUI
(本文算是对文章利用hsdis和JITWatch查看分析HotSpot JIT compiler生成的汇编代码关于JITwatch安装一部分的更新)
版权声明:本文为博主原创文章,未经博主允许不得转载。