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

Java Module & Ahead Of Time (AOT) Compilation: ...

Java Module & Ahead Of Time (AOT) Compilation: Battle of Efficiency

After years, the JVM was built for applications that last days, months to years, but with adoption of distributed architectures such as microservices and the native cloud movement this requirement has changed and no longer uses a JVM for long-term applications but of a more effective JVM with no computational resource requirement.

Aiming at this, it was released in Java 9 or supports modularity, but we have other features that enhance the compilation techniques, such as Aheaf Of Time (AOT) Compilation and Just In Time Compilation (JIT).

Therefore, in this talk I will compare the embassies in which providers or the quantities needed to capture more assertive decisions on future projects.

Luram Archanjo

November 27, 2019
Tweet

More Decks by Luram Archanjo

Other Decks in Technology

Transcript

  1. Who am I? • Software Engineer at Sensedia • MBA

    in Java projects • Java and Microservice enthusiastic
  2. Agenda • Microservices • Java Module • Ahead Of Time

    Compilation (AOT) • Just In Time Compilation (JIT) • Native Image • Questions
  3. Moving to Microservices Feature A Feature B Feature C Monolith

    Microservice Microservice Microservices Microservice
  4. Scalability Feature A Monolith Scalability Microservice Microservice Microservices Scalability Microservice

    Microservice Microservice Microservice Microservice Microservice Microservice Microservice Feature B Feature C Feature A Feature B Feature C Feature A Feature B Feature C Waste Waste Waste Waste Waste
  5. Java Module Source: https://jcp.org/en/jsr/detail?id=376 & https://www.oracle.com/corporate/features/understanding-java-9-modules.html Modularity adds a higher

    level of aggregation above packages. The key new language element is the module - a uniquely named, reusable group of related packages, as well as resources and a module descriptor specifying. According to JSR 376, the key goals of modularizing the Java SE platform are: • Reliable Configuration • Strong Encapsulation • Greater Platform Integrity • Scalable Java Platform • Improved Performance Module Package Class Field Method
  6. Java Module java.se java.sql.rowset java.sql java.logging java.naming java.rmi java.scripting java.xml

    java.base java.datatransfer java.compiler java.desktop JDK Modules java.sql java.logging java.naming java.base java.compiler Application & Custom JRE module-info.java module myApp { exports com.tdc.poa; requires java.base; requires java.sql; requires java.logging; requires java.naming; requires java.compiler; }
  7. What are the results of using Reflection? Spring is an

    amazing technical achievement and does so many things, but does them at Runtime. • Reads the byte code of every bean it finds. • Synthesizes new annotations for each annotation on each bean method, constructor, field etc. to support Annotation metadata. • Builds Reflective Metadata for each bean for every method, constructor, field etc.
  8. Ahead Of Time (AOT) Compilation Ahead-of-time compilation (AOT compilation) is

    the act of compiling a higher-level programming language, or an intermediate representation such as Java bytecode, into a native machine code so that the resulting binary file can execute natively. Web Android Java Google Dagger 2
  9. Data from Micronaut website: • Startup time around a second.

    • All Dependency Injection, AOP and Proxy generation happens at compile time. • Can be run with as little as 180mb Max Heap. What are the results of using Ahead Of Time (AOT) Compilation?
  10. Data from Quarkus website: • Startup time around two seconds.

    • All Dependency Injection, AOP and Proxy generation happens at compile time. • Can be run with as little as 145mb Max Heap. What are the results of using Ahead Of Time (AOT) Compilation?
  11. GraalVM is a universal virtual machine for running applications written

    in JavaScript, Python, Ruby, R, JVM-based languages like Java, Scala, Groovy, Kotlin, Clojure, and LLVM-based languages such as C and C++ • Native Image • Embeddable For Java Programs For existing Java applications, GraalVM can provide benefits by running them faster, providing a faster Just In Time (JIT) Compilation Source: https://www.graalvm.org/docs/why-graal/ what is?
  12. Just In Time (JIT) compilation is a way of executing

    computer code that involves compilation during execution of a program. It runs complex optimizations to generate high-quality machine code Just In Time (JIT) Compilation System.out.println( "Hello World"); Source code 6a 61 76 61 20 c3 a9 20 66 6f 64 61 Byte code 01101010 01100001 01110110 01100001 00100000 11101001 00100000 01100110 01101111 01100100 01100001 Machine code JIT
  13. GraalVM Native Image, currently available as an Early Adopter Technology

    Native image works well when: • Little or no runtime reflection is used. • Limited or no dynamic classloading. Source: https://www.graalvm.org/docs/why-graal/ Native Image
  14. When to start using Java Module, JIT or AOT? New

    Application Java Module • Java 9 Just In Time Compilation • GraalVM Ahead Of Time Compilation • Quarkus • Micronaut Native Image • GraalVM ◦ Early Adopter Technology Existent Application Java Module • Java 9 Just In Time Compilation • GraalVM