Pro Yearly is on sale from $80 to $50! »

Javaの起動時間といかに戦うか / How to fight against Java warmup time

9e840766611f942c7c0a9ad6987a5d78?s=47 Naoki Kishida
November 23, 2019

Javaの起動時間といかに戦うか / How to fight against Java warmup time

2019/11/23に開催されたJJUG CCC 2019 Fallでの登壇資料です

9e840766611f942c7c0a9ad6987a5d78?s=128

Naoki Kishida

November 23, 2019
Tweet

Transcript

  1. Java    2019/11/23 JJUG CCC 2019 Fall LINE

    Fukoka  
  2.  •   • LINE Fukuoka • @kis •

    Hatena (nowokay.hatenablog.com)
  3.  • # "!' & • Java # • #

     •  • Java 14 $   %
  4.  • # "!' & • Java # • #

     •  • Java 14 $   %
  5.      • $'#  :8" @)

    74 . • /6$'#  "&  2 • ,> ;(*8  • "0B< • % ! 15 ?+  • -=9<3A
  6.  • # "!' & • Java # • #

     •  • Java 14 $   %
  7. Java • JVM •   •  • 

         (JIT) Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU
  8.  • # "!' & • Java # • #

     •  • Java 14 $   %
  9.    •      •

    JIT    • JIT  •   
  10.    •      or

       •  • OpenJDK CDS(Class Data Sharing) Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU !
  11. Class Data Sharing • Java 5 Bootstrap CDS • Java

    10 App CDS(JEP 310) •  % • Java 12 Default CDS(JEP 341) • Bootstrap CDS  &( •   '$ • Java 13 Dynamic CDS(JEP 350) • ! CDS#"
  12. JIT     •    JVM

    •  • Alibaba Dragonwell - JWarmup Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU 
  13. JIT • JIT  JVM   •  •

    OpenJ9 • Azul Zing - Falcon JIT Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU 
  14. JIT • JITJIT     • OpenJ9 •

    JIT as a Service(JITaaS) • https://www.youtube.com/watch?v=gx8DVVFPkcQ
  15.    • AOT(Ahead of Time compile) • Java

          •  • GraalVM native image • Java 9 AOT (JEP 295) Point to analysis Java Bytecode loading class generate native code internal expression native code Execute on CPU   Run initialization Heap snapshot
  16. JITAOT JIT AOT   $    

     #! "      CPU &%'
  17. AOT •  • JIT     AOT

    Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU Point to analysis Java Bytecode loading class generate native code internal expression native code Execute on CPU Run initialization Heap snapshot
  18. profile guided optimization • GraalVM EEJIT   native-image

  19.  • # "!' & • Java # • #

     •  • Java 14 $   %
  20.  • OpenJDK • HotSpot JDK  • GraalVM 

  21. Micronaut • Micronaut   • Micronaut main  

     main    ↓ System.out.println(ManagementFactory.getRuntimeMXBean().getUptime());
  22. OpenJDK   • Java 8 Java 13 • CDS

    • AOT •    • Compact String  •    
  23. Java8Java13 • Java 13   0 200 400 600

    800 1000 1200 1400 Java 8 Java 13 VM   
  24. CDS • Java 12Default CDSCDS  • 13 Default CDSJava

    13   0 200 400 600 800 1000 1200 1400 Java 8 13 No CDS 13 Default CDS 13 Dynamic CDS 13 App CDS VM 
  25. HotSpotJDK  • OpenJ9JIT • GragonwellMac   Linux 

    JWarmup  • Azul Zing !   0 200 400 600 800 1000 1200 1400 Java 8 Java 13 13 App CDS OpenJ9 OpenJ9 JIT Cache VM 
  26. GraalVM native image • native image 0 200 400 600

    800 1000 1200 1400 Java 8 Java 13 13 App CDS native image VM 
  27. native image   •    0 5

    10 15 20 25 30 35 40 45 Java 8 Java 13 CE JIT EE JIT CE AOT EE AOT 
  28. profile guided optimization •   0 5 10 15

    20 25 30 35 40 45 Java 8 Java 13 CE JIT EE JIT CE AOT EE AOT PGO 
  29.  • App CDS   • native-image 0 50

    100 150 200 250 300 350 Java 8 Java 13 13 App CDS OpenJ9 JIT Cache GraalVM JIT GraalVM AOT 
  30.  • # "!' & • Java # • #

     •  • Java 14 $   %
  31. Java 14   • static final   •

    GraalVM JIT   • JWarmup
  32. static final     • https://openjdk.java.net/jeps/8209964 • 

    ↓ •       private final static Logger LOGGER = Logger.getLogger("com.foo.Bar");
  33. Graal JIT    • https://openjdk.java.net/jeps/8223220 • OpenJDK 

    Graal JIT Java    JIT#% • " • native-image shared library  !$ 0 500 1000 1500 2000 Java 8 Java 13 13 + Graal VM" " 0 50 100 150 200 Java 8 Java 13 13 + Graal 
  34. JWarmup • https://openjdk.java.net/jeps/8203832 • GragonwellJWarmupOpenJDK