Skip to content
Chris Newland edited this page Jun 28, 2014 · 53 revisions

Video introduction to JITWatch

https://skillsmatter.com/skillscasts/5243-chris-newland-hotspot-profiling-with-jit-watch

Slides from my LJC lightning talk on JITWatch:

http://www.chrisnewland.com/images/jitwatch/HotSpot_Profiling_Using_JITWatch.pdf


Description

A tool for understanding the behaviour of the Java HotSpot Just-In-Time (JIT) compiler during the execution of your program.

Works by processing the hotspot.log file output by the JVM.

I built this tool as a learning vehicle to gain a better understanding of HotSpot and JavaFX.


Mailing list

For usage questions, bug reports, feature requests, and general chat about JIT, HotSpot, JVM, bytecode and performance tuning please join the list at https://groups.google.com/forum/#!forum/jitwatch


Why would I use this tool?

  • To verify whether methods you believe to be performance-critical were JIT-compiled during the program's execution.
  • To learn when your performance-critical methods were compiled.
  • For visualising the effects of tuning JVM compilation thresholds.
  • To gain a better understanding of the HotSpot JIT compiler.
  • To have a nice interface for inspecting method bytecode and assembly?

Features

  • Browse class trees and view which methods were JIT-compiled, when JIT-compilation occurred, and information about the compilation.
  • Mount your source, jars, and class trees to jump to the source, bytecode, and assembly for a method.
  • Plot JIT compilations over time and visualise when a method was JIT-compiled.
  • View toplists of the largest native methods, methods with most bytecodes, longest compilation times, etc.
  • Open sourced under the Simplified BSD licence.

Download a pre-built jar

Pre-built jars are now produced by Jenkins CI. See the README for details


Instructions

To generate the hotspot.log file used by JITWatch run your program with the following JVM switches.

-XX:+UnlockDiagnosticVMOptions -XX:+TraceClassLoading -XX:+LogCompilation -XX:+PrintAssembly

The hotspot.log file is generated in the program execution directory.

If you want to use the -XX:+PrintAssembly switch to view the assembly language (disassembled JIT-compiled native code) then you need to use a debug JVM build or have built the hsdis (HotSpot disassembler) binary. The source for hsdis is part of OpenJDK.

Instructions for building hsdis (for Windows) are here: Building hsdis on Windows

Instructions for building hsdis (for Linux) are here: [Building hsdis on Linux] (http://www.chrisnewland.com/building-hsdis-on-linux-amd64-on-debian-369)

-XX:+TraceClassLoading is required. This is how JITWatch builds the class model.

JavaFX (JAVA_HOME/jre/lib/jfxrt.jar for jdk1.7 or JAVA_HOME/jre/lib/ext/jfxrt.jar for jdk8) and tools.jar (JDK_HOME/lib/tools.jar) are required to run JITWatch.

Example launch script (Linux):

#!/bin/sh

export CP=$JDK_HOME/lib/tools.jar:$JDK_HOME/jre/lib/jfxrt.jar:jitwatch.jar

$JDK_HOME/bin/java -cp $CP com.chrisnewland.jitwatch.launch.LaunchUI


Found a bug?

Please report it using the Issue Tracker


Acknowledgements

Thanks to Martijn Verburg for maven help and lots of useful suggestions! Thanks to Mani Sarkar for code improvements!

Thanks to Dr Heinz Kabutz and the participants of JCrete 2013 for an amazing unconference and inspiring me to up my Java game.

The idea for building this tool came after reading The Well Grounded Java Developer by Ben Evans and Martijn Verburg.


Want to know more about HotSpot logs?

Oracle HotSpot Internals wiki LogCompilation

Oracle HotSpot Internals wiki PrintAssembly

OpenJDK HotSpot Glossary

My "Understanding HotSpot Logs" session at the JCrete (un)conference (Open Spaces)

Slides on Understanding HotSpot Logs

More on performance tuning


Feedback

Love it? Hate it? Want a new feature? Let me know!

Twitter: @chriswhocodes

Email : chris@chrisnewland.com


Screenshots

Main JITWatch application window.

Main JITWatch application window

Configure JITWatch by mounting src trees, class folders, and jars.

Configure JITWatch by mounting src trees, class folders, and jars

Browse the package tree and inspect methods.

Browse the package tree and inspect methods

Right click a method to show detailed inspection tools

Right click a method to show detailed inspection tools

JIT Sandbox: Edit->Compile->Execute->Analyse fast feedback loop.

JIT Sandbox: Edit->Compile->Execute->Analyse fast feedback loop.

JIT Sandbox: Experiment with various HotSpot JIT Compilation options.

JIT Sandbox: Experiment with various HotSpot JIT Compilation options.

TriView combined source, bytecode, assembly viewer.

TriView combined source, bytecode, assembly viewer.

Bytecode annotations for inlining and branch taken probability.

Bytecode annotations for inlining and branch taken probability

Compile Chain showing JIT-compiled and inlined members.

Compile Chain showing JIT-compiled and inlined members

Suggestion tool - highlights hot method inlining failures and unpredictable branches.

Suggestion tool - highlights hot method inlining failures and unpredictable branches.

Chart of compilations over time. Selected method is shown.

Chart of compilations over time. Selected method is shown

Toplists of largest native methods, highest bytecode count, longest compile time, etc.

Toplists of largest native methods, highest bytecode count, longest compile time, etc

Histograms of compile times, method sizes, etc.

Histograms of compile times, method sizes, etc.

JIT Journal: Find all the log statements associated with a method.

JIT Journal: Find all the log statements associated with a method.

Statistics on JIT compilations made by HotSpot.

Statistics on JIT compilations made by HotSpot.