object layout schemes in JVMs. These tools are using Unsafe, JVMTI, and Serviceability Agent (SA) heavily to decoder the actual object layout, footprint, and references. This makes JOL much more accurate than other tools relying on heap dumps, specifcation assumptions, etc. http://openjdk.java.net/projects/code-tools/jol/
[optional arguments]* Available modes: estimates: Simulate the class layout in different VM modes. externals: Show the object externals: the objects reachable from a given instance. footprint: Estimate the footprint of all objects reachable from a given instance heapdump: Consume the heap dump and estimate the savings in different layout strategies. heapdumpstats: Consume the heap dump and print the most frequent instances. idealpack: Compute the object footprint under different field layout strategies. internals: Show the object internals: field layout and default contents, object header shapes: Dump the object shapes present in JAR files or heap dumps. string-compress: Consume the heap dumps and figures out the savings attainable with compressed strings.
class JOLSample_02_Alignment { public static void main(String[] args) throws Exception { out.println(VM.current().details()); out.println(ClassLayout.parseClass(A.class).toPrintable()); } public static class A { long f; } } Alignment
Exception { out.println(VM.current().details()); final A a = new A(); ClassLayout layout = ClassLayout.parseInstance(a); out.println("**** Fresh object"); out.println(layout.toPrintable()); out.println("hashCode: " + Integer.toHexString(a.hashCode())); out.println(); out.println("**** After identityHashCode()"); out.println(layout.toPrintable()); } public static class A { } } Object header
a single component • Compare performance of diferent algorithms/implementations • Investigate impact of confguration and/or environment changes on a performance of your system
running, and analyzing nano/micro/milli/macro benchmarks written in Java and other languages targeting the JVM • De-facto standard for writing benchmarks on JVM • JEP 230: Microbenchmark Suite (Status: Candidate)
Parameters and state Support for multi-threaded benchmarks Blackhole, compiler control etc… • Command line and API for running benchmarks • Built-in proflers
and a suite of tests to aid the research in the correctness of concurrency support in the JVM, class libraries, and hardware. http://openjdk.java.net/projects/code-tools/jcstress/
implements Counter { private int value; @Override public int increment() { return ++value; } } public class AtomicCounter implements Counter { private final AtomicInteger value = new AtomicInteger(); @Override public int increment() { return value.incrementAndGet(); } } Counter
JIT log -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:LogFile=$LogFilePath • Get the assembly -XX:+PrintAssembly Requires the hsdis (HotSpot disassembler) binary to be added to your JRE. See https://github.com/AdoptOpenJDK/jitwatch/wiki/Building-hsdis
in JVMs • JMH – Swiss army knife of benchmarking. Gives you powerful tools to write correct benchmarks and investigate performance problems • JCStress – harness for writing concurrency tests and a suit of such tests for JVM (JMM, core libraries, Hotspot, hardware) • JITWatch – log analyser and visualiser for the HotSpot JIT compiler