Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TechEvent Graal(VM) Performance Interoperability

118 views

Published on

Graal(VM) - new era in JVM performance and languages interoperability

Published in: Technology
  • Be the first to comment

  • Be the first to like this

TechEvent Graal(VM) Performance Interoperability

  1. 1. BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH Graal(VM) – new era in JVM performance and languages interoperability Gilles DuboscqGilles Duboscq Jonatan KazmierczakJonatan Kazmierczak Andy MoncsekAndy Moncsek
  2. 2. Copyright © 2018, Oracle and/or its aliates. All rights reserved. ● Working at Oracle Labs Zürich ● Working on Graal for 7 years ● Research interests: ● Virtual machines ● Compilers ● Specula-ve op-miza-ons Gilles Duboscq
  3. 3. Graal(VM) – performance and interoperability Jonatan Kazmierczak  senior consultant at Trivadis  creator of Class Visualizer  contributor to Graal  uses Java for 20+ years  creates software for 29 years
  4. 4. Graal(VM) – performance and interoperability Andy Moncsek n principal consultant at Trivadis n creator of ... see my github n Wrote his first program on a 2.5MHz PC n conference speaker n Likes coffee HiFi
  5. 5. Graal(VM) – performance and interoperability Agenda  Introduction  JVM, JIT, AOT, SVM – what are we talking about?  More details and some demos  GraalVM, Graal, Substrate VM  Time of the truth – benchmark results  Summary + Q A
  6. 6. Copyright © 2018, Oracle and/or its aliates. All rights reserved. Safe Harbor Statement The following is intended to provide some insight into a line of research in Oracle Labs. It is intended for informa-on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func-onality, and should not be relied upon in making purchasing decisions. The development, release, and -ming of any features or func-onality described in connec-on with any Oracle product or service remains at the sole discre-on of Oracle. Any views expressed in this presenta-on are my own and do not necessarily re6ect the views of Oracle. 2
  7. 7. Graal(VM) – performance and interoperability IntroductionIntroduction
  8. 8. Graal(VM) – performance and interoperability What is JIT compiler?
  9. 9. Graal(VM) – performance and interoperability What is JIT compiler? Just-in-time compiler working at runtime:  performs advanced optimizations of Java bytecode  compiles Java bytecode to platform-speci3c machine code and stores it in memory  recompilations are possible
  10. 10. Graal(VM) – performance and interoperability What is AOT compiler? Ahead-of-time compiler:  performs simple optimizations of Java bytecode  transforms Java bytecode into machine code and stores it in an OS-speci3c binary 3le
  11. 11. Graal(VM) – performance and interoperability What is C2 ?  JIT compiler used by default by JVM  Introduced about 20 years ago (long before Java 8) – not enough support for modern language features  written in C++ – extremely di6cult to maintain and extend
  12. 12. Graal(VM) – performance and interoperability What is Graal ?  modern compiler available as experimental feature – can be used as JIT compiler and AOT compiler  introduced in JDK 9  supports language features introduced in Java 8  written in Java – modular and easily maintainable
  13. 13. Graal(VM) – performance and interoperability What is GraalVM ?  universal virtual machine for running applications written in various languages  it removes the isolation between programming languages and enables interoperability in a shared runtime  it can be integrated in various native and managed deployments (OpenJDK, Node.js, Oracle DB, MySQL, ...)
  14. 14. Graal(VM) – performance and interoperability What is Substrate VM (SVM)?  it is an embeddable VM  written for and in a subset of Java  optimized to execute dynamic languages  ahead-of-time compiled using Graal  integrating with native development tools
  15. 15. Graal(VM) – performance and interoperability GraalVMGraalVM
  16. 16. Copyright © 2018, Oracle and/or its aliates. All rights reserved. 4 Why GraalVM: Polyglot Challenges Only languages with high industry a:en-on achieve high performance. Languages require di;erent tools for conguring, debugging, proling… Languages execute in their own box with costly serializa-on between boxes.
  17. 17. Copyright © 2018, Oracle and/or its aliates. All rights reserved. 5 GraalVM Vision High performance for all languages Common plaorm for shared manageability and tooling Zero overhead interoperability between languages
  18. 18. Copyright © 2018, Oracle and/or its aliates. All rights reserved. 6 GraalVM Extended Vision High performance, polyglot, common pla@orm… embeddable across the stack in na-ve and JVM-based applica-ons.
  19. 19. Copyright © 2018, Oracle and/or its aliates. All rights reserved. 7 GraalVM Extended Vision
  20. 20. Graal(VM) – performance and interoperability GraalGraal
  21. 21. Graal(VM) – performance and interoperability Sample application  real world solution  simple microservice  depends only on 2 JDK modules:  java.base  jdk.httpserver  link to the project: github.com/jonatan-kazmierczak/simple-microservice
  22. 22. Graal(VM) – performance and interoperability How to turn on Graal JIT ?  run a sample application on C2 JIT (default) java -jar simple-microservice.jar  run a sample application on Graal JIT java -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler -jar simple-microservice.jar
  23. 23. Graal(VM) – performance and interoperability JIT – Graal vs C2  Pros  Better performance of long-running applications  Cons  Slower startup time  Heap used for compilations – more heap space may be required
  24. 24. Graal(VM) – performance and interoperability How to use Graal (JDK) AOT ?  compile sample application using Graal (JDK) AOT jaotc --output app.so --jar simple-microservice.jar --module jdk.httpserver --module java.base  run a sample application using generated machine code java -XX:AOTLibrary=./app.so -jar simple-microservice.jar
  25. 25. Graal(VM) – performance and interoperability Execution – AOT-compiled vs JIT-compiled  Pros  Faster startup time  Cons  Worse performance of long-running applications  Huge size of natively compiled code
  26. 26. Graal(VM) – performance and interoperability SubstrateVMSubstrateVM
  27. 27. Substrate VM Graal(VM) – performance and interoperability _ http://www.oracle.com/technetwork/java/jvmls2015-wimmer-2637907.pdf
  28. 28. Substrate VM Graal(VM) – performance and interoperability _ http://www.oracle.com/technetwork/java/jvmls2015-wimmer-2637907.pdf
  29. 29. Graal(VM) – performance and interoperability How to create a native app?  Download Install GraalVM (http://www.graalvm.org/docs/getting-started/)  Build a (fat) jar (maven, gradle,…)  native-image -jar simple-microservice.jar  ./simple-microservice
  30. 30. Graal(VM) – performance and interoperability SVM advantagas  Self-contained native executables  Fast process start  Small distribution size  Memory footprint may be smaller
  31. 31. Graal(VM) – performance and interoperability Limitations SVM { name : java.lang.String, fields : [ { name : value }, { name : hash } ], methods : [ { name : init, parameterTypes : [] }, { name : init, parameterTypes : [char[]] } } Reflection configuration:
  32. 32. Graal(VM) – performance and interoperability Limitations recap  Not every JVM application can be compiled to SVM  There is no JIT  and no optimizations during run-time  optimizations through instrumentations possible  The garbage-collector is simpler
  33. 33. Graal(VM) – performance and interoperability So why SVM AOT? n Different target group / alignment to HotSpot n Cloud, Container, Functions, IoT n Small volatile n Jakarte EE / Desktop out of scope https://medium.com/oracledevs/helidon-takes-flight-fb7e9e390e9c
  34. 34. Graal(VM) – performance and interoperability SummarySummary withQAwithQA
  35. 35. Graal(VM) – performance and interoperability Benchmark and statistics Mode Initialization [ms] Execution [µs] UsedRAM [MB] Distributionsize [MB] C2JIT 990 66 424 0+JDK GraalJIT 2100 59 420 0+JDK JDKAOT 690 136 423 316(so/dll)+JDK SVMAOT 1280 87 516 9(executable)
  36. 36. Copyright © 2018, Oracle and/or its aliates. All rights reserved. Possibili$es With GraalVM, you could: • Run your exis-ng JVM applica-on more eciently • Run your exis-ng R, Ruby, JS, Python applica-on more eciently • Run those languages in the same VM with ecient interoperability • Embed those languages in a JVM or na-ve applica-on Graal compiler available in the JDK GraalVM
  37. 37. Copyright © 2018, Oracle and/or its aliates. All rights reserved. Inspec$ng performance • Use the perf tool on Linux • Use Oracle Developer Studio’s Performance Analyzer
  38. 38. Copyright © 2018, Oracle and/or its aliates. All rights reserved. Future • Pla@orms: – Windows support JDK 11 is coming to GraalVM – libgraal ● Separate heap to avoid interac-on with applica-on GC tuning ● Removes start-up/warm-up costs of Graal
  39. 39. Copyright © 2018, Oracle and/or its aliates. All rights reserved. Resources on GraalVM 11 graalvm.org
  40. 40. Thank you!Thank you!

×