SlideShare a Scribd company logo
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Full Speed Ahead! (Ahead-of-Time
Compilation for Java SE)
CON3738
David Buck
Principal Member of Technical Staff
Java Platform Group
October 4th, 2017
Confidential – Oracle Internal/Restricted/Highly Restricted 3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
Confidential – Oracle Internal/Restricted/Highly Restricted 4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• JVM Sustaining Engineer
• OpenJDK 8 Update Project
Maintainer
• JavaOne Rock Star
• Co-author of Oracle WebLogic
Server 11g 構築・運用ガイド
• @DavidBuckJP
• https://blogs.oracle.com/buck/
Hi There!
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Warnings
AoT Basics
Similar Functionality
Usage
1
2
3
4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Warnings
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Warnings
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Warnings
• AoT is still experimental and not yet officially supported
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Warnings
• AoT is still experimental and not yet officially supported
• Currently only Linux on AMD64 (w/ libelf.so) is supported
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Warnings
• AoT is still experimental and not yet officially supported
• Currently only Linux on AMD64 (w/ libelf.so) is supported
• No official documentation (only the JEP)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Warnings
• AoT is still experimental and not yet officially supported
• Currently only Linux on AMD64 (w/ libelf.so) is supported
• No official documentation (only the JEP)
• There is no official roadmap for support yet
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
AoT Basics
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why learn about Java AoT?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why learn about Java AoT?
• May be supported in the future
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why learn about Java AoT?
• May be supported in the future
• Excuse to study other HotSpot technologies
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why learn about Java AoT?
• May be supported in the future
• Excuse to study other HotSpot technologies
• Fun
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Java Build / Execution Model (Interpreter)
MyClass.java MyClass.class java
(HotSpot)
javac
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Java Build / Execution Model (JIT)
MyClass.java MyClass.class java
(HotSpot)
javac
Machine
Language
(in memory)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
• Methods get compiled
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
• Methods get compiled
• Compilation is expensive (both in cpu time and memory)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
• Methods get compiled
• Compilation is expensive (both in cpu time and memory)
• ML version is fast
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
• Methods get compiled
• Compilation is expensive (both in cpu time and memory)
• ML version is fast
• Is JIT really faster than an interpreter?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
Better performance than an interpreter?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
Better performance than an interpreter?
Depends on your definition of “performance”
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ time ./hello_j1
Hello JavaOne!
real 0m0.002s
user 0m0.001s
$ time java HelloJ1
Hello JavaOne!
real 0m0.104s
user 0m0.077s
sys 0m0.020s
Just in Time Compilation (JIT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
Weak Point
• Compilation overhead is high
– Delay before native code can be executed
– Heavy resource (memory / CPU cycles) consumption
• Interpretation is better for non-hot methods
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT)
(HotSpot’s Implimentation)
• All methods start off being interpreted
• Hot methods identified by sample-based profiling
• Hot methods are compiled
• Non-hot methods continue to be interpreted
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Even with HotSpot’s JIT
• Application startup time is longer
• It takes longer to achieve peak performance
• Compilation consumes a lot of memory
• There are platforms where runtime code generation is not allowed
Compared to native (C/C++) compilation
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Just in Time Compilation (JIT) HotSpot’s Implementation
A tale of two compilers…
• C2
– For server use
– Heavy optimization
– Dependent on profiling data collected by the interpreter
– Default CompileThreshold: 10000
• C1
– For client use
– Less optimization
– Not dependent on profiling data
– Default CompileThreshold : 1500
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Ahead of Time (AoT) Strategy
• Generate machine code before runtime
• Load preexisting machine code during runtime
• No need to JIT compile code at runtime
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Java Build / Execution Model (AoT)
MyClass.java MyClass.class java
(HotSpot)
javac
Machine
Language
(in memory)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Java Build / Execution Model (AoT)
MyClass.java MyClass.class java
(HotSpot)
javac
my_class.so
jaotc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Java Build / Execution Model
java
(HotSpot)
Machine
Language
(in memory)
java
(HotSpot)
Machine
Language
(in memory)
java
(HotSpot)
Machine
Language
(in memory)
java
(HotSpot)
Machine
Language
(in memory)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Java Build / Execution Model
java
(HotSpot)
java
(HotSpot)
java
(HotSpot)
java
(HotSpot)
my_class.so
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
• Faster startup times ★
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
• Faster startup times ★
• Less time to peak performance / steady state ★
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
• Faster startup times ★
• Less time to peak performance / steady state ★
• Less runtime compilation overhead (CPU / memory) ★
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
• Faster startup times ★
• Less time to peak performance / steady state ★
• Less runtime compilation overhead (CPU / memory) ★
• Native code can be shared across multiple processes ★
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
• Faster startup times ★
• Less time to peak performance / steady state ★
• Less runtime compilation overhead (CPU / memory) ★
• Native code can be shared across multiple processes ★
• Native code performance even on platforms that disallow JIT ★
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Advantages of Ahead of Time (AoT)
• Faster startup times ★
• Less time to peak performance / steady state ★
• Less runtime compilation overhead (CPU / memory) ★
• Native code can be shared across multiple processes ★
• Native code performance even on platforms that disallow JIT ★
★ YMMV
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Similar Functionality
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Similar Functionality
• Tiered Compilation
• Class Data Sharing(CDS) / AppCDS
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tiered Compilation
• Server JVM without Tiered Compilation
– Interpreter (w/ profiling)
– C2
• Server JVM with Tiered Compilation
– Interpreter (w/ profiling)
– C1 (w/ profiling)
– C2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
No Class Data Sharing
java
(HotSpot)
Class Data
(in memory)java
(HotSpot)
Class Data
(in memory)
java
(HotSpot)
Class Data
(in memory)
java
(HotSpot)
Class Data
(in memory)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Class Data Sharing
java
(HotSpot)
java
(HotSpot)
java
(HotSpot)
java
(HotSpot)
Class Data
classes.jsa
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• Class Data Sharing
– Only Java SE Class Library
• AppCDS
– Includes application classes as well
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Same as AoT
• Tiered Compilation
– Quicker warm up
• Class Data Sharing(CDS) / AppCDS
– Quicker warm up
– Lower total memory footprint
Different from AoT
• No machine (native) code is
persisted or shared
Similar Functionality
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Corporate Photography Collection
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Usage
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
A New Tool: jaotc
MyClass.class my_class.sojaotc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --output libHelloAOT.so HelloAoT.class
jaotc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --help
Usage: jaotc <options> list
list A : separated list of class names, modules, jar files
or directories which contain class files.
where options include:
--output <file> Output file name
--class-name <class names> List of classes to compile
--jar <jarfiles> List of jar files to compile
--module <modules> List of modules to compile
--directory <dirs> List of directories where to search for files to compile
--search-path <dirs> List of directories where to search for specified files
--compile-commands <file> Name of file with compile commands
--compile-for-tiered Generate profiling code for tiered compilation
--compile-with-assertions Compile with java assertions
--compile-threads <number> Number of compilation threads to be used
--ignore-errors Ignores all exceptions thrown during class loading
--exit-on-error Exit on compilation errors
--info Print information during compilation
--verbose Print verbose information
--debug Print debug information
--help Print this usage message
--version Version information
-J<flag> Pass <flag> directly to the runtime system
jaotc (On-line Help)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --info --output libHelloAOT.so HelloAoT.class
Compiling libHelloAOT...
1 classes found (30 ms)
2 methods total, 2 methods to compile (4 ms)
Compiling with 8 threads
.
2 methods compiled, 0 methods failed (409 ms)
Parsing compiled code (1 ms)
Processing metadata (15 ms)
Preparing stubs binary (1 ms)
Preparing compiled binary (1 ms)
Creating binary: libHelloAOT.o (8 ms)
Creating shared library: libHelloAOT.so (13 ms)
Total time: 912 ms
jaotc (--info Flag)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --info --compile-with-assertions --output libHelloAOT.so HelloAoT.class
jaotc (--compile-with-assertions Flag)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --compile-commands cc.txt --output libHelloAOT.so HelloAoT.class
$ cat cc.txt
exclude org.sample.code.MyClass.method*
exclude org.sample.code.MyClass.<init>
jaotc (--compile-commands Flag)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --output libjava.base.so --module java.base
jaotc (Modules)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc --output libjava.base.so --jar my-spiffy-app.jar
jaotc (Jar Files)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc -J-XX:-UseCompressedOop --output libHelloAOT.so HelloAoT.class
VM Options are important here! (more to come…)
jaotc (VM Options)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
jaotc (--compile-for-tiered Flag)
• jaotc uses Graal to compile
• Performance is similar to C1
• --compile-for-tiered generates code that includes profiling instrumentation
needed by C2
Confidential – Oracle Internal/Restricted/Highly Restricted 65
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ java -XX:AOTLibrary=./libHelloAoT.so HelloAoT
Runtime
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ java -XX:AOTLibrary=./libHelloAoT.so HelloAoT
Hello AoT!
$
Runtime
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ java -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT
Runtime (-XX:+/-PrintAOT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ builds/jdk-9/bin/java -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT
13 1 loaded ./libHelloAoT.so aot library
76 1 aot[ 1] HelloAoT.<init>()V
76 2 aot[ 1] HelloAoT.main([Ljava/lang/String;)V
Hello AoT!
$
Runtime (-XX:+/-PrintAOT)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ java -XX:-UseCompressedOops -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT
Runtime (Compressed Oops Disabled)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ java -XX:-UseCompressedOops -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT
Shared file ./libHelloAoT.so error: UseCompressedOops has different value 'true' from
current 'false'
7 1 skipped ./libHelloAoT.so aot library
Hello AoT!
$
Runtime (Compressed Oops Disabled)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ builds/jdk-9/bin/java -XX:-UseCompressedOops -XX:AOTLibrary=./libHelloAoT.so HelloAoT
Hello AoT!
$
Runtime (Compressed Oops Disabled)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
$ jaotc -J-XX:-UseCompressedOop --output libHelloAOT.so HelloAoT.class
jaotc (Be sure to synchronize VM options)
Compressed OOPs Normal OOPs
G1 -J-XX:+UseCompressedOops
-J-XX:+UseG1GC
-J-XX:-UseCompressedOops
-J-XX:+UseG1GC
ParallelGC -J-XX:+UseCompressedOops
-J-XX:+UseParallelGC
-J-XX:-UseCompressedOops
-J-XX:+UseParallelGC
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is < 4GB, 32 MSB of every heap address is the same!
• We can store just the 32 LSB of each address
• Each reference field is half the size
Confidential – Oracle Internal/Restricted/Highly Restricted 74
Compressed Oops
64-bit Address
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is < 4GB, 32 MSB of every heap address is the same!
• We can store just the 32 LSB of each address
• Each reference field is half the size
Confidential – Oracle Internal/Restricted/Highly Restricted 75
Compressed Oops
32 MSB 32 LSB
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is < 4GB, 32 MSB of every heap address is the same!
• We can store just the 32 LSB of each address
• Each reference field is half the size
Confidential – Oracle Internal/Restricted/Highly Restricted 76
Compressed Oops
Always the same! 32 LSB
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is < 4GB, 32 MSB of every heap address is the same!
• We can store just the 32 LSB of each address
• Each reference field is half the size
Confidential – Oracle Internal/Restricted/Highly Restricted 77
Compressed Oops
32 LSB
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is < 4GB, 32 MSB of every heap address is the same!
• We can store just the 32 LSB of each address
• Each reference field is half the size
• uncompressed_oop = heap_base + compressed_oop
Confidential – Oracle Internal/Restricted/Highly Restricted 78
Compressed Oops
32 LSB
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is > than 4GB but < 32GB we can still compress the Oop
• 64-bit platform has an 8-byte alignment requirement
• 3 LSB of every heap address are always zero
• So we can shift the address 3 bits right/left to compress/uncompress
Confidential – Oracle Internal/Restricted/Highly Restricted 79
Compressed Oops
64-bit Address
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is > than 4GB but < 32GB we can still compress the Oop
• 64-bit platform has an 8-byte alignment requirement
• 3 LSB of every heap address are always zero
• So we can shift the address 3 bits right/left to compress/uncompress
Confidential – Oracle Internal/Restricted/Highly Restricted 80
Compressed Oops
64-bit Address 000
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is > than 4GB but < 32GB we can still compress the Oop
• 64-bit platform has an 8-byte alignment requirement
• 3 LSB of every heap address are always zero
• So we can shift the address 3 bits right/left to compress/uncompress
Confidential – Oracle Internal/Restricted/Highly Restricted 81
Compressed Oops
32-bit 000
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is > than 4GB but < 32GB we can still compress the Oop
• 64-bit platform has an 8-byte alignment requirement
• 3 LSB of every heap address are always zero
• So we can shift the address 3 bits right/left to compress/uncompress
Confidential – Oracle Internal/Restricted/Highly Restricted 82
Compressed Oops
32-bit
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• If heap is > than 4GB but < 32GB we can still compress the Oop
• 64-bit platform has an 8-byte alignment requirement
• 3 LSB of every heap address are always zero
• So we can shift the address 3 bits right/left to compress/uncompress
• uncompressed_oop = heap_base + (compressed_oop << 3)
Confidential – Oracle Internal/Restricted/Highly Restricted 83
Compressed Oops
32-bit
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 84
Write Barriers
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 85
Write Barriers
Young Not Young
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 86
Write Barriers
Young Not Young! New
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 87
Write Barriers
Young Not Young! New !
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 88
Write Barriers
Young Not Young
Card Table
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 89
Write Barriers
Young Not Young! New
Card Table
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Why do we need to synchronize VM Options?
• To avoid marking the entire heap, we need to keep track of changes
Confidential – Oracle Internal/Restricted/Highly Restricted 90
Write Barriers
Young Not Young! New !
Card Table
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Known Library Locations ($JAVA_HOME/lib/)
• -XX:-UseCompressedOops -XX:+UseG1GC : libjava.base.so
• -XX:+UseCompressedOops -XX:+UseG1GC : libjava.base-coop.so
• -XX:-UseCompressedOops -XX:+UseParallelGC : libjava.base-nong1.so
• -XX:+UseCompressedOops -XX:+UseParallelGC : libjava.base-coop-nong1.so
Confidential – Oracle Internal/Restricted/Highly Restricted 91
VMOptions must match library name
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Known Library Locations ($JAVA_HOME/lib/)
• jdk.compiler
• jdk.scripting.nashorn
• jdk.vm.ci
• jdk.vm.compiler
Confidential – Oracle Internal/Restricted/Highly Restricted 92
Other known JDK modules
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Summary
• Value
– System reaches peak performance quicker ★
– Reduced total footprint of multiple JVMs running same code ★
– Native code performance on platforms that do not allow JIT ★
• Risks
– Still experimental, not officially supported
– No official documentation (besides the JEP)
– Only available on AMD64 Linux
– Does not support invokedynamic (JSR 292) or custom classloaders
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Summary
• Value
– System reaches peak performance quicker ★
– Reduced total footprint of multiple JVMs running same code ★
– Native code performance on platforms that do not allow JIT ★
• Risks
– Still experimental, not officially supported
– No official documentation (besides the JEP)
– Only available on AMD64 Linux
– Does not support invokedynamic (JSR 292) or custom classloaders
★ YMMV
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Other AoT Sessions at J1
• HotSpot AOT Internals and AOT + CDS Performance Results [CON7772]
– Thursday, Oct 05, 11:00 a.m. - 11:45 a.m. | Marriott Marquis (Yerba Buena Level) -
Salon 12
– JVMLS version of talk: https://www.youtube.com/watch?v=n5DCg6M2MDM
• JIT Versus AOT: Unity and Conflict of Dynamic and Static Compilers for Java
[CON3230]
– Thursday, Oct 05, 1:00 p.m. - 1:45 p.m. | Marriott Marquis (Yerba Buena Level) - Salon
14
Confidential – Oracle Internal/Restricted/Highly Restricted 95
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
References
• JEP 295: Ahead-of-Time Compilation
http://openjdk.java.net/jeps/295
• Tiered Compilation
https://docs.oracle.com/javase/8/docs/technotes/guides/vm/performance-enhancements-7.html#tieredcompilation
• Class Data Sharing
https://docs.oracle.com/javase/8/docs/technotes/guides/vm/class-data-sharing.html
• JEP draft: Application Class Data Sharing
http://openjdk.java.net/jeps/8185996
• Ahead Of Time (AOT) Internals with Vladimir Kozlov and Igor Veresov
https://www.youtube.com/watch?v=n5DCg6M2MDM
Confidential – Oracle Internal/Restricted/Highly Restricted 96
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Stay connected
• Join us: DevOps Corner (Developer Lounge – Moscone West)
• Learn more: openjdk.java.net | wercker.com/java
• Follow: @OpenJDK, @wercker #JavaOne #DevOps
97
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The preceding is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
Confidential – Oracle Internal/Restricted/Highly Restricted 98
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]

More Related Content

PDF
Cloud Native Java GraalVM 이상과 현실
PDF
Cloud Native Java:GraalVM
PDF
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
PPTX
[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
PDF
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
PDF
Nashorn in the future (English)
PDF
Adopt-a-JSR for JSON Processing 1.1, JSR 374
PDF
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java:GraalVM
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
[ScalaMatsuri] グリー初のscalaプロダクト!チャットサービス公開までの苦労と工夫
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
Nashorn in the future (English)
Adopt-a-JSR for JSON Processing 1.1, JSR 374
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...

What's hot (20)

PDF
Dockerizing Oracle Database
PDF
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
PPTX
JSF 2.3 Adopt-a-JSR 10 Minute Infodeck
PDF
20191119 Cloud Native Java : GraalVM
PDF
JavaCro'15 - HTTP2 Comes to Java! - David Delabassee
PPTX
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
PPT
Apache Harmony: An Open Innovation
PDF
WebSocket in Enterprise Applications 2015
PDF
Oracle Cloud: Anything as a Service
PDF
JavaOne 2014 BOF4241 What's Next for JSF?
PDF
Server Side JavaScript on the Java Platform - David Delabassee
PDF
GraphPipe - Blazingly Fast Machine Learning Inference by Vish Abrams
PDF
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
PDF
Supercharge your Code to get optimal Database Performance
PDF
Tweet4Beer - Beertap powered by Java goes IoT and JavaFX
PDF
JCP 20 Year Anniversary
PDF
Introdução ao Oracle NoSQL
PDF
EJB and CDI - Alignment and Strategy
PDF
WebSockets - Realtime em Mundo Conectado
Dockerizing Oracle Database
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
JSF 2.3 Adopt-a-JSR 10 Minute Infodeck
20191119 Cloud Native Java : GraalVM
JavaCro'15 - HTTP2 Comes to Java! - David Delabassee
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Apache Harmony: An Open Innovation
WebSocket in Enterprise Applications 2015
Oracle Cloud: Anything as a Service
JavaOne 2014 BOF4241 What's Next for JSF?
Server Side JavaScript on the Java Platform - David Delabassee
GraphPipe - Blazingly Fast Machine Learning Inference by Vish Abrams
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
Supercharge your Code to get optimal Database Performance
Tweet4Beer - Beertap powered by Java goes IoT and JavaFX
JCP 20 Year Anniversary
Introdução ao Oracle NoSQL
EJB and CDI - Alignment and Strategy
WebSockets - Realtime em Mundo Conectado
Ad

Similar to Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738] (20)

PDF
Hotspot & AOT
PDF
Compile ahead of time. It's fine?
PDF
Understand the Trade-offs Using Compilers for Java Applications
PDF
Another compilation method in java - AOT (Ahead of Time) compilation
PPTX
Keeping Your Java Hot by Solving the JVM Warmup Problem
PPTX
Java On CRaC
PDF
Java Cloud and Container Ready
PDF
GraalVM Overview Compact version
PDF
JVM JIT compilation overview by Vladimir Ivanov
PPTX
Ahead-Of-Time Compilation of Java Applications
PDF
Java is Container Ready - Vaibhav - Container Conference 2018
PDF
GraalVM Native Images by Oleg Selajev @shelajev
PDF
Владимир Иванов. JIT для Java разработчиков
PPTX
JIT vs. AOT: Unity And Conflict of Dynamic and Static Compilers
PDF
Modern Cloud-Native Jakarta EE Frameworks: tips, challenges, and trends.
PDF
10 Reasons Why Java Now Rocks More Than Ever
PPTX
Java Jit. Compilation and optimization by Andrey Kovalenko
PPTX
Java performance tuning
PDF
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
PDF
What the CRaC - Superfast JVM startup
Hotspot & AOT
Compile ahead of time. It's fine?
Understand the Trade-offs Using Compilers for Java Applications
Another compilation method in java - AOT (Ahead of Time) compilation
Keeping Your Java Hot by Solving the JVM Warmup Problem
Java On CRaC
Java Cloud and Container Ready
GraalVM Overview Compact version
JVM JIT compilation overview by Vladimir Ivanov
Ahead-Of-Time Compilation of Java Applications
Java is Container Ready - Vaibhav - Container Conference 2018
GraalVM Native Images by Oleg Selajev @shelajev
Владимир Иванов. JIT для Java разработчиков
JIT vs. AOT: Unity And Conflict of Dynamic and Static Compilers
Modern Cloud-Native Jakarta EE Frameworks: tips, challenges, and trends.
10 Reasons Why Java Now Rocks More Than Ever
Java Jit. Compilation and optimization by Andrey Kovalenko
Java performance tuning
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
What the CRaC - Superfast JVM startup
Ad

More from David Buck (20)

PDF
JDK 13 New Features [MeetUp with Java Experts! @Gaienmae/Dojima 2019]
PDF
JDK Mission Control: Where We Are, Where We Are Going [Groundbreakers APAC 20...
PDF
Java Bytecode Crash Course [Code One 2019]
PDF
CSI (Crash Scene Investigation) HotSpot: Common JVM Crash Causes and Solution...
PDF
invokedynamic for Mere Mortals [Code One 2019]
PDF
Hangs, Slowdowns, Starvation—Oh My! A Deep Dive into the Life of a Java Threa...
PDF
JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]
PDF
Java Concurrency, A(nother) Peek Under the Hood [Code One 2019]
PDF
Z Garbage Collector
PDF
Valhalla Update JJUG CCC Spring 2019
PDF
Var handles jjug_ccc_spring_2018
PDF
JDK 10 へようこそ
PDF
Java SE 8におけるHotSpotの進化 [Java Day Tokyo 2014 C-2]
PDF
HotSpot のロック: A Peek Under the Hood [JJUG ナイトセミナ JVM 特集 2015年8月]
PDF
Java Concurrency, A(nother) Peek Under the Hood [JavaOne 2016 CON1497]
PDF
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
PDF
Java Debuggers: A Peek Under the Hood [JavaOne 2016 CON1503]
PDF
Lambda: A Peek Under The Hood [Java Day Tokyo 2015 6-3]
PDF
Java Concurrency, A(nother) Peek Under the Hood [Java Day Tokyo 2016 3-C]
PDF
Ahead-of-Time Compilation with JDK 9 [Java Day Tokyo 2017 D1-A1]
JDK 13 New Features [MeetUp with Java Experts! @Gaienmae/Dojima 2019]
JDK Mission Control: Where We Are, Where We Are Going [Groundbreakers APAC 20...
Java Bytecode Crash Course [Code One 2019]
CSI (Crash Scene Investigation) HotSpot: Common JVM Crash Causes and Solution...
invokedynamic for Mere Mortals [Code One 2019]
Hangs, Slowdowns, Starvation—Oh My! A Deep Dive into the Life of a Java Threa...
JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]
Java Concurrency, A(nother) Peek Under the Hood [Code One 2019]
Z Garbage Collector
Valhalla Update JJUG CCC Spring 2019
Var handles jjug_ccc_spring_2018
JDK 10 へようこそ
Java SE 8におけるHotSpotの進化 [Java Day Tokyo 2014 C-2]
HotSpot のロック: A Peek Under the Hood [JJUG ナイトセミナ JVM 特集 2015年8月]
Java Concurrency, A(nother) Peek Under the Hood [JavaOne 2016 CON1497]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Java Debuggers: A Peek Under the Hood [JavaOne 2016 CON1503]
Lambda: A Peek Under The Hood [Java Day Tokyo 2015 6-3]
Java Concurrency, A(nother) Peek Under the Hood [Java Day Tokyo 2016 3-C]
Ahead-of-Time Compilation with JDK 9 [Java Day Tokyo 2017 D1-A1]

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Introduction to Artificial Intelligence
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
L1 - Introduction to python Backend.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
top salesforce developer skills in 2025.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context
Introduction to Artificial Intelligence
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Upgrade and Innovation Strategies for SAP ERP Customers
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Operating system designcfffgfgggggggvggggggggg
PTS Company Brochure 2025 (1).pdf.......
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
2025 Textile ERP Trends: SAP, Odoo & Oracle
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
L1 - Introduction to python Backend.pptx
Softaken Excel to vCard Converter Software.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
top salesforce developer skills in 2025.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx

Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]

  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) CON3738 David Buck Principal Member of Technical Staff Java Platform Group October 4th, 2017 Confidential – Oracle Internal/Restricted/Highly Restricted 3
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Confidential – Oracle Internal/Restricted/Highly Restricted 4
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • JVM Sustaining Engineer • OpenJDK 8 Update Project Maintainer • JavaOne Rock Star • Co-author of Oracle WebLogic Server 11g 構築・運用ガイド • @DavidBuckJP • https://blogs.oracle.com/buck/ Hi There!
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Program Agenda Warnings AoT Basics Similar Functionality Usage 1 2 3 4
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Warnings
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Warnings
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Warnings • AoT is still experimental and not yet officially supported
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Warnings • AoT is still experimental and not yet officially supported • Currently only Linux on AMD64 (w/ libelf.so) is supported
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Warnings • AoT is still experimental and not yet officially supported • Currently only Linux on AMD64 (w/ libelf.so) is supported • No official documentation (only the JEP)
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Warnings • AoT is still experimental and not yet officially supported • Currently only Linux on AMD64 (w/ libelf.so) is supported • No official documentation (only the JEP) • There is no official roadmap for support yet
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | AoT Basics
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why learn about Java AoT?
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why learn about Java AoT? • May be supported in the future
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why learn about Java AoT? • May be supported in the future • Excuse to study other HotSpot technologies
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why learn about Java AoT? • May be supported in the future • Excuse to study other HotSpot technologies • Fun
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Java Build / Execution Model (Interpreter) MyClass.java MyClass.class java (HotSpot) javac
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Java Build / Execution Model (JIT) MyClass.java MyClass.class java (HotSpot) javac Machine Language (in memory)
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT)
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) • Methods get compiled
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) • Methods get compiled • Compilation is expensive (both in cpu time and memory)
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) • Methods get compiled • Compilation is expensive (both in cpu time and memory) • ML version is fast
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) • Methods get compiled • Compilation is expensive (both in cpu time and memory) • ML version is fast • Is JIT really faster than an interpreter?
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT)
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT)
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) Better performance than an interpreter?
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) Better performance than an interpreter? Depends on your definition of “performance”
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ time ./hello_j1 Hello JavaOne! real 0m0.002s user 0m0.001s $ time java HelloJ1 Hello JavaOne! real 0m0.104s user 0m0.077s sys 0m0.020s Just in Time Compilation (JIT)
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) Weak Point • Compilation overhead is high – Delay before native code can be executed – Heavy resource (memory / CPU cycles) consumption • Interpretation is better for non-hot methods
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) (HotSpot’s Implimentation) • All methods start off being interpreted • Hot methods identified by sample-based profiling • Hot methods are compiled • Non-hot methods continue to be interpreted
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Even with HotSpot’s JIT • Application startup time is longer • It takes longer to achieve peak performance • Compilation consumes a lot of memory • There are platforms where runtime code generation is not allowed Compared to native (C/C++) compilation
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Just in Time Compilation (JIT) HotSpot’s Implementation A tale of two compilers… • C2 – For server use – Heavy optimization – Dependent on profiling data collected by the interpreter – Default CompileThreshold: 10000 • C1 – For client use – Less optimization – Not dependent on profiling data – Default CompileThreshold : 1500
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Ahead of Time (AoT) Strategy • Generate machine code before runtime • Load preexisting machine code during runtime • No need to JIT compile code at runtime
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Java Build / Execution Model (AoT) MyClass.java MyClass.class java (HotSpot) javac Machine Language (in memory)
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Java Build / Execution Model (AoT) MyClass.java MyClass.class java (HotSpot) javac my_class.so jaotc
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Java Build / Execution Model java (HotSpot) Machine Language (in memory) java (HotSpot) Machine Language (in memory) java (HotSpot) Machine Language (in memory) java (HotSpot) Machine Language (in memory)
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Java Build / Execution Model java (HotSpot) java (HotSpot) java (HotSpot) java (HotSpot) my_class.so
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT)
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT) • Faster startup times ★
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT) • Faster startup times ★ • Less time to peak performance / steady state ★
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT) • Faster startup times ★ • Less time to peak performance / steady state ★ • Less runtime compilation overhead (CPU / memory) ★
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT) • Faster startup times ★ • Less time to peak performance / steady state ★ • Less runtime compilation overhead (CPU / memory) ★ • Native code can be shared across multiple processes ★
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT) • Faster startup times ★ • Less time to peak performance / steady state ★ • Less runtime compilation overhead (CPU / memory) ★ • Native code can be shared across multiple processes ★ • Native code performance even on platforms that disallow JIT ★
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Advantages of Ahead of Time (AoT) • Faster startup times ★ • Less time to peak performance / steady state ★ • Less runtime compilation overhead (CPU / memory) ★ • Native code can be shared across multiple processes ★ • Native code performance even on platforms that disallow JIT ★ ★ YMMV
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | ?
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Similar Functionality
  • 48. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Similar Functionality • Tiered Compilation • Class Data Sharing(CDS) / AppCDS
  • 49. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tiered Compilation • Server JVM without Tiered Compilation – Interpreter (w/ profiling) – C2 • Server JVM with Tiered Compilation – Interpreter (w/ profiling) – C1 (w/ profiling) – C2
  • 50. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | No Class Data Sharing java (HotSpot) Class Data (in memory)java (HotSpot) Class Data (in memory) java (HotSpot) Class Data (in memory) java (HotSpot) Class Data (in memory)
  • 51. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Class Data Sharing java (HotSpot) java (HotSpot) java (HotSpot) java (HotSpot) Class Data classes.jsa
  • 52. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • Class Data Sharing – Only Java SE Class Library • AppCDS – Includes application classes as well
  • 53. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Same as AoT • Tiered Compilation – Quicker warm up • Class Data Sharing(CDS) / AppCDS – Quicker warm up – Lower total memory footprint Different from AoT • No machine (native) code is persisted or shared Similar Functionality
  • 54. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Corporate Photography Collection
  • 55. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Usage
  • 56. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | A New Tool: jaotc MyClass.class my_class.sojaotc
  • 57. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --output libHelloAOT.so HelloAoT.class jaotc
  • 58. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --help Usage: jaotc <options> list list A : separated list of class names, modules, jar files or directories which contain class files. where options include: --output <file> Output file name --class-name <class names> List of classes to compile --jar <jarfiles> List of jar files to compile --module <modules> List of modules to compile --directory <dirs> List of directories where to search for files to compile --search-path <dirs> List of directories where to search for specified files --compile-commands <file> Name of file with compile commands --compile-for-tiered Generate profiling code for tiered compilation --compile-with-assertions Compile with java assertions --compile-threads <number> Number of compilation threads to be used --ignore-errors Ignores all exceptions thrown during class loading --exit-on-error Exit on compilation errors --info Print information during compilation --verbose Print verbose information --debug Print debug information --help Print this usage message --version Version information -J<flag> Pass <flag> directly to the runtime system jaotc (On-line Help)
  • 59. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --info --output libHelloAOT.so HelloAoT.class Compiling libHelloAOT... 1 classes found (30 ms) 2 methods total, 2 methods to compile (4 ms) Compiling with 8 threads . 2 methods compiled, 0 methods failed (409 ms) Parsing compiled code (1 ms) Processing metadata (15 ms) Preparing stubs binary (1 ms) Preparing compiled binary (1 ms) Creating binary: libHelloAOT.o (8 ms) Creating shared library: libHelloAOT.so (13 ms) Total time: 912 ms jaotc (--info Flag)
  • 60. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --info --compile-with-assertions --output libHelloAOT.so HelloAoT.class jaotc (--compile-with-assertions Flag)
  • 61. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --compile-commands cc.txt --output libHelloAOT.so HelloAoT.class $ cat cc.txt exclude org.sample.code.MyClass.method* exclude org.sample.code.MyClass.<init> jaotc (--compile-commands Flag)
  • 62. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --output libjava.base.so --module java.base jaotc (Modules)
  • 63. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc --output libjava.base.so --jar my-spiffy-app.jar jaotc (Jar Files)
  • 64. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc -J-XX:-UseCompressedOop --output libHelloAOT.so HelloAoT.class VM Options are important here! (more to come…) jaotc (VM Options)
  • 65. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | jaotc (--compile-for-tiered Flag) • jaotc uses Graal to compile • Performance is similar to C1 • --compile-for-tiered generates code that includes profiling instrumentation needed by C2 Confidential – Oracle Internal/Restricted/Highly Restricted 65
  • 66. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ java -XX:AOTLibrary=./libHelloAoT.so HelloAoT Runtime
  • 67. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ java -XX:AOTLibrary=./libHelloAoT.so HelloAoT Hello AoT! $ Runtime
  • 68. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ java -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT Runtime (-XX:+/-PrintAOT)
  • 69. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ builds/jdk-9/bin/java -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT 13 1 loaded ./libHelloAoT.so aot library 76 1 aot[ 1] HelloAoT.<init>()V 76 2 aot[ 1] HelloAoT.main([Ljava/lang/String;)V Hello AoT! $ Runtime (-XX:+/-PrintAOT)
  • 70. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ java -XX:-UseCompressedOops -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT Runtime (Compressed Oops Disabled)
  • 71. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ java -XX:-UseCompressedOops -XX:+PrintAOT -XX:AOTLibrary=./libHelloAoT.so HelloAoT Shared file ./libHelloAoT.so error: UseCompressedOops has different value 'true' from current 'false' 7 1 skipped ./libHelloAoT.so aot library Hello AoT! $ Runtime (Compressed Oops Disabled)
  • 72. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ builds/jdk-9/bin/java -XX:-UseCompressedOops -XX:AOTLibrary=./libHelloAoT.so HelloAoT Hello AoT! $ Runtime (Compressed Oops Disabled)
  • 73. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | $ jaotc -J-XX:-UseCompressedOop --output libHelloAOT.so HelloAoT.class jaotc (Be sure to synchronize VM options) Compressed OOPs Normal OOPs G1 -J-XX:+UseCompressedOops -J-XX:+UseG1GC -J-XX:-UseCompressedOops -J-XX:+UseG1GC ParallelGC -J-XX:+UseCompressedOops -J-XX:+UseParallelGC -J-XX:-UseCompressedOops -J-XX:+UseParallelGC
  • 74. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is < 4GB, 32 MSB of every heap address is the same! • We can store just the 32 LSB of each address • Each reference field is half the size Confidential – Oracle Internal/Restricted/Highly Restricted 74 Compressed Oops 64-bit Address
  • 75. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is < 4GB, 32 MSB of every heap address is the same! • We can store just the 32 LSB of each address • Each reference field is half the size Confidential – Oracle Internal/Restricted/Highly Restricted 75 Compressed Oops 32 MSB 32 LSB
  • 76. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is < 4GB, 32 MSB of every heap address is the same! • We can store just the 32 LSB of each address • Each reference field is half the size Confidential – Oracle Internal/Restricted/Highly Restricted 76 Compressed Oops Always the same! 32 LSB
  • 77. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is < 4GB, 32 MSB of every heap address is the same! • We can store just the 32 LSB of each address • Each reference field is half the size Confidential – Oracle Internal/Restricted/Highly Restricted 77 Compressed Oops 32 LSB
  • 78. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is < 4GB, 32 MSB of every heap address is the same! • We can store just the 32 LSB of each address • Each reference field is half the size • uncompressed_oop = heap_base + compressed_oop Confidential – Oracle Internal/Restricted/Highly Restricted 78 Compressed Oops 32 LSB
  • 79. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is > than 4GB but < 32GB we can still compress the Oop • 64-bit platform has an 8-byte alignment requirement • 3 LSB of every heap address are always zero • So we can shift the address 3 bits right/left to compress/uncompress Confidential – Oracle Internal/Restricted/Highly Restricted 79 Compressed Oops 64-bit Address
  • 80. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is > than 4GB but < 32GB we can still compress the Oop • 64-bit platform has an 8-byte alignment requirement • 3 LSB of every heap address are always zero • So we can shift the address 3 bits right/left to compress/uncompress Confidential – Oracle Internal/Restricted/Highly Restricted 80 Compressed Oops 64-bit Address 000
  • 81. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is > than 4GB but < 32GB we can still compress the Oop • 64-bit platform has an 8-byte alignment requirement • 3 LSB of every heap address are always zero • So we can shift the address 3 bits right/left to compress/uncompress Confidential – Oracle Internal/Restricted/Highly Restricted 81 Compressed Oops 32-bit 000
  • 82. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is > than 4GB but < 32GB we can still compress the Oop • 64-bit platform has an 8-byte alignment requirement • 3 LSB of every heap address are always zero • So we can shift the address 3 bits right/left to compress/uncompress Confidential – Oracle Internal/Restricted/Highly Restricted 82 Compressed Oops 32-bit
  • 83. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • If heap is > than 4GB but < 32GB we can still compress the Oop • 64-bit platform has an 8-byte alignment requirement • 3 LSB of every heap address are always zero • So we can shift the address 3 bits right/left to compress/uncompress • uncompressed_oop = heap_base + (compressed_oop << 3) Confidential – Oracle Internal/Restricted/Highly Restricted 83 Compressed Oops 32-bit
  • 84. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 84 Write Barriers
  • 85. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 85 Write Barriers Young Not Young
  • 86. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 86 Write Barriers Young Not Young! New
  • 87. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 87 Write Barriers Young Not Young! New !
  • 88. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 88 Write Barriers Young Not Young Card Table
  • 89. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 89 Write Barriers Young Not Young! New Card Table
  • 90. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Why do we need to synchronize VM Options? • To avoid marking the entire heap, we need to keep track of changes Confidential – Oracle Internal/Restricted/Highly Restricted 90 Write Barriers Young Not Young! New ! Card Table
  • 91. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Known Library Locations ($JAVA_HOME/lib/) • -XX:-UseCompressedOops -XX:+UseG1GC : libjava.base.so • -XX:+UseCompressedOops -XX:+UseG1GC : libjava.base-coop.so • -XX:-UseCompressedOops -XX:+UseParallelGC : libjava.base-nong1.so • -XX:+UseCompressedOops -XX:+UseParallelGC : libjava.base-coop-nong1.so Confidential – Oracle Internal/Restricted/Highly Restricted 91 VMOptions must match library name
  • 92. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Known Library Locations ($JAVA_HOME/lib/) • jdk.compiler • jdk.scripting.nashorn • jdk.vm.ci • jdk.vm.compiler Confidential – Oracle Internal/Restricted/Highly Restricted 92 Other known JDK modules
  • 93. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Summary • Value – System reaches peak performance quicker ★ – Reduced total footprint of multiple JVMs running same code ★ – Native code performance on platforms that do not allow JIT ★ • Risks – Still experimental, not officially supported – No official documentation (besides the JEP) – Only available on AMD64 Linux – Does not support invokedynamic (JSR 292) or custom classloaders
  • 94. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Summary • Value – System reaches peak performance quicker ★ – Reduced total footprint of multiple JVMs running same code ★ – Native code performance on platforms that do not allow JIT ★ • Risks – Still experimental, not officially supported – No official documentation (besides the JEP) – Only available on AMD64 Linux – Does not support invokedynamic (JSR 292) or custom classloaders ★ YMMV
  • 95. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Other AoT Sessions at J1 • HotSpot AOT Internals and AOT + CDS Performance Results [CON7772] – Thursday, Oct 05, 11:00 a.m. - 11:45 a.m. | Marriott Marquis (Yerba Buena Level) - Salon 12 – JVMLS version of talk: https://www.youtube.com/watch?v=n5DCg6M2MDM • JIT Versus AOT: Unity and Conflict of Dynamic and Static Compilers for Java [CON3230] – Thursday, Oct 05, 1:00 p.m. - 1:45 p.m. | Marriott Marquis (Yerba Buena Level) - Salon 14 Confidential – Oracle Internal/Restricted/Highly Restricted 95
  • 96. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | References • JEP 295: Ahead-of-Time Compilation http://openjdk.java.net/jeps/295 • Tiered Compilation https://docs.oracle.com/javase/8/docs/technotes/guides/vm/performance-enhancements-7.html#tieredcompilation • Class Data Sharing https://docs.oracle.com/javase/8/docs/technotes/guides/vm/class-data-sharing.html • JEP draft: Application Class Data Sharing http://openjdk.java.net/jeps/8185996 • Ahead Of Time (AOT) Internals with Vladimir Kozlov and Igor Veresov https://www.youtube.com/watch?v=n5DCg6M2MDM Confidential – Oracle Internal/Restricted/Highly Restricted 96
  • 97. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Stay connected • Join us: DevOps Corner (Developer Lounge – Moscone West) • Learn more: openjdk.java.net | wercker.com/java • Follow: @OpenJDK, @wercker #JavaOne #DevOps 97
  • 98. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Confidential – Oracle Internal/Restricted/Highly Restricted 98