Understand the trade-offs using compilers for Java applications
(From AOT to JIT and Beyond!)
Mark Stoodley Eclipse OpenJ9 & OMR project co-lead Senior Software Developer @ IBM Canada mstoodle@ca.ibm.com @mstoodle
Understand the trade-offs using compilers for Java applications - - PowerPoint PPT Presentation
Understand the trade-offs using compilers for Java applications (From AOT to JIT and Beyond!) Mark Stoodley Eclipse OpenJ9 & OMR project co-lead Senior Software Developer @ IBM Canada mstoodle@ca.ibm.com @mstoodle Java ecosystem has a
Mark Stoodley Eclipse OpenJ9 & OMR project co-lead Senior Software Developer @ IBM Canada mstoodle@ca.ibm.com @mstoodle
2
4
5
6
7
8
JIT Code Performance (steady state) Runtime: adapt to changes Ease of use Platform neutral deployment Start up (ready to handle load) Ramp up (until steady state) Runtime: CPU & Memory
9
JIT Code Performance (steady state) Runtime: adapt to changes Ease of use Platform neutral deployment Start up (ready to handle load) Ramp up (until steady state) Runtime: CPU & Memory
Everyone hopes: Maybe AOT helps here?
10
11
and its dependencies evolve
12
”Big bang” (java process created) Time
13
”Big bang” (java process created) JVM loaded, initialized & about to load first class to run main()
14
Time
”Big bang” (java process created) Finally ready to run main() ~ 750 classes loaded, handful of class loader
App class loading and init, can be 100s active class loaders, 1000s classes
15
JVM loaded, initialized & about to load first class to run main()
Time
”Big bang” (java process created) App class loading and initialization phase, up to 100s active class loaders, 10,000s classes
16
Finally ready to run main() ~ 750 classes loaded, handful of class loader
JVM loaded, initialized & about to load first class to run main() Time
”Big bang” (java process created) Ready to do application work: begin exercising code paths May load more classes, may invalidate early assumptions
17
Finally ready to run main() ~ 750 classes loaded, handful of class loader
JVM loaded, initialized & about to load first class to run main() Startup Time
”Big bang” (java process created) Ready to do application work: begin exercising code paths May load more classes, may invalidate early assumptions Code paths & profile stabilizes
18
Finally ready to run main() ~ 750 classes loaded, handful of class loader
JVM loaded, initialized & about to load first class to run main() Rampup Startup Time
”Big bang” (java process created) Ready to do application work: begin exercising code paths May load more classes, may invalidate early assumptions Code paths & profile stabilizes
19
Finally ready to run main() ~ 750 classes loaded, handful of class loader
JVM loaded, initialized & about to load first class to run main() Rampup Startup Time
”Big bang” (java process created) Ready to do application work: begin exercising code paths May load more classes, may invalidate early assumptions Code paths & profile stabilizes
20
Finally ready to run main() ~ 750 classes loaded, handful of class loader
JVM loaded, initialized & about to load first class to run main() Rampup Startup Time
21
public void foo() {
B b = get_a_b(); = b.bar(); …
}
class B { public int bar() { return 5; } }
22
public void foo() {
B b = get_a_b(); = 5; //b.bar(); …
}
class B { public int bar() { return 5; } }
23
public void foo() {
B b = get_a_b(); = 5; //b.bar(); …
}
ClassLoader CL1 class B { public int bar() { return 5; } } C B
24
public void foo() {
B b = get_a_b(); = 5; //b.bar(); …
}
ClassLoader CL1 class B { public int bar() { return 5; } } C B Java heap
25
public void foo() {
B b = get_a_b(); b.bar(); // 5 or -5? …
}
ClassLoader CL1 ClassLoader CL2 class B { public int bar() { return 5; } } class B { public int bar() { return -5; } } C C B B Java heap
26
public void foo() {
B b = get_a_b(); b.bar(); // 5 or -5? …
}
ClassLoader CL1 ClassLoader CL2 class B { public int bar() { return 5; } } class B { public int bar() { return -5; } } C C B B Java heap
27
public void foo() {
B b = get_a_b(); b.bar(); // 5 or -5? …
}
ClassLoader CL1 ClassLoader CL2 class B { public int bar() { return 5; } } class B { public int bar() { return -5; } } C C B B Java heap
28
to be loaded at the same time (i.e. jar file hell)
dynamically and even created on the fly?
29
30
JIT AOT Code Performance (steady state) Runtime: adapt to changes Ease of use Platform neutral deployment Start up (ready to handle load) Ramp up (until steady state) Runtime: CPU & Memory
31
JIT AOT AOT +JIT Code Performance (steady state) Runtime: adapt to changes Ease of use Platform neutral deployment Start up (ready to handle load) Ramp up (until steady state) Runtime: CPU & Memory
32
33
34
1. ”Dynamic AOT” in Eclipse OpenJ9 open source JVM1
2. “Compile Stashing”in Azul’s proprietary Falcon JIT 2
1 https://blog.openj9.org/2018/10/10/intro-to-ahead-of-time-compilation/ 2 https://www.slideshare.net/dougqh/readynow-azuls-unconventional-aot 35
naturally and transparently at runtime
to accelerate ramp-up (under load)
36
20 40 60 80 100 120
OpenJ9 no SCC OpenJ9 default SCC OpenJ9 full SCC HotSpot
Normalized start-up time
Apache Tomcat 8 Start-up Time
28% 43% 19%
* Technically an internal format that can load faster than a .class file
JIT AOT AOT +JIT Cache JIT Code Performance (steady state) Runtime: adapt to changes Ease of use Platform neutral deployment Start up (ready to handle load) * Ramp up (until steady state) * Runtime: CPU & Memory * * After first run
37
38
39
JIT
JVM
JIT Server
JIT
JVM
JIT
JVM
Orchestrator
load balancing, affinity, scaling, reliability
JIT Server JVM client identifies methods to compile, but asks server to do the actual compilation
40
41
42
All JVMs run in containers, client and server on different machines with direct cable connection Note: Hotspot takes twice as long as OpenJ9 to ramp up to about the same performance level
1000 2000 3000 4000 5000 6000 100 200 300 400 500 600
Throughput (pages/sec)
Time (sec)
AcmeAir with -Xshareclasses (Cold Run) Container limits: 1P, 150M JITServer-cold OpenJ9-cold
1000 2000 3000 4000 5000 6000 100 200 300 400 500 600
Throughput (pages/sec)
Time (sec)
AcmeAir with -Xshareclasses (Warm Run) Container limits: 1P, 150M JITServer-warm OpenJ9-warm
43
200 400 600 800 1000 1200 1400 100 200 300 400 500 600
Throughput (pages/sec) Time (sec)
JITServer OpenJ9
200 400 600 800 1000 1200 1400 100 200 300 400 500 600
Throughput (pages/sec) Time (sec)
JITServer OpenJ9
200 400 600 800 1000 1200 1400 100 200 300 400 500 600
Throughput (pages/sec) Time (sec)
JITServer OpenJ9 Smaller memory limit
44
45
46
* JITaaS == JIT Server
JIT AOT AOT +JIT Cache JIT JIT Server Code Performance (steady state) Runtime: adapt to changes Ease of use Platform Neutral deployment Start up (ready to handle load) * ** Ramp up (until steady state) * ** Runtime: CPU & Memory * * After first run ** After first run across cluster
47
binaries (JDK8 and up) at AdoptOpenJDK
48
49
performance to be less than JIT performance
up even for large complex JakartaEE applications
50
51
Select “OpenJ9” Button!!
52
CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
INFRASTRUCTURE DIFFERENCES.
PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE.
OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION.
OR THEIR SUPPLIERS AND/OR LICENSORS
53
IBM and the IBM logo are trademarks or registered trademarks of IBM Corporation, in the United States, other countries or both. Java and all Java-based marks, among others, are trademarks or registered trademarks of Oracle in the United States, other countries or both. Other company, product and service names may be trademarks or service marks of others. THE INFORMATION DISCUSSED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES
IT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, AND IBM SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, SUCH
CHANGE BY IBM WITHOUT NOTICE.
54
55
caches very efficient with new SCC layers
layer that is independent of lower SCC layers
upper layers won’t add to it
images that package a SCC
Docker registry
56
84 8 17 6 84 18 21 8 84 26 25 10
50 100 150 200 250
On Disk Over Net On Disk Over Net Single-Layer SCC Multi-Layer SCC Total SCC Image Size (MiB)
Single- vs Multi-Layer SCC
App Layer SCC Liberty Layer SCC Java Layer SCC