Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

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

Naoki Kishida

November 23, 2019
Tweet

More Decks by Naoki Kishida

Other Decks in Programming

Transcript

  1.  •   • LINE Fukuoka • @kis •

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

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

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

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

     •  • Java 14 $   %
  6. Java • JVM •   •  • 

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

     •  • Java 14 $   %
  8.    •      •

    JIT    • JIT  •   
  9.    •      or

       •  • OpenJDK CDS(Class Data Sharing) Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU !
  10. 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#"
  11. JIT     •    JVM

    •  • Alibaba Dragonwell - JWarmup Java Bytecode loading class interpret profile generate native code internal expression profile data native code Execute on CPU 
  12. 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 
  13. JIT • JITJIT     • OpenJ9 •

    JIT as a Service(JITaaS) • https://www.youtube.com/watch?v=gx8DVVFPkcQ
  14.    • 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
  15. JITAOT JIT AOT   $    

     #! "      CPU &%'
  16. 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
  17.  • # "!' & • Java # • #

     •  • Java 14 $   %
  18. Micronaut • Micronaut   • Micronaut main  

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

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

    800 1000 1200 1400 Java 8 Java 13 VM   
  21. 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 
  22. 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 
  23. GraalVM native image • native image 0 200 400 600

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

    10 15 20 25 30 35 40 45 Java 8 Java 13 CE JIT EE JIT CE AOT EE AOT 
  25. 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 
  26.  • 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 
  27.  • # "!' & • Java # • #

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

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

    ↓ •       private final static Logger LOGGER = Logger.getLogger("com.foo.Bar");
  30. 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