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

What GraalVM means for the Eclipse IDE

What GraalVM means for the Eclipse IDE

Martin Lippert

October 22, 2019
Tweet

More Decks by Martin Lippert

Other Decks in Programming

Transcript

  1. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What is this GraalVM thing?
  2. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Overview https://graalvm.org/: High-performance polyglot VM Basic idea: • One virtual machine that can execute all languages (Java, JavaScript, R, Ruby, Python, C, C++, Kotlin, Scala, etc.) • You can run all those languages without any boundaries between them
  3. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ GraalVM Java Scala Kotlin JavaScript Ruby R Python C++ OpenJDK Node JS Oracle Database MySQL Native
  4. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Graal compiler • The Graal compiler is at the center of everything • it is a highly optimizing compiler • written in Java • In an OpenJDK setting, it replaces the HotSpot JIT compiler • and adds additional API to the outside world
  5. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Non-JVM based languages • each language needs to be implemented for the Graal compiler • to make this easier, there is the Truffle framework (now called Language Implementation Framework) • you basically write an interpreter for the language based on an AST • the framework and the compiler turns this into high-performance compiled code for the language • JavaScript performance, for example, is comparable to V8 • + you get full interoperability between languages
  6. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ GraalVM architecture HotSpot VM Graal Compiler JVM languages Truffle (Language Implementation Framework) JavaScript implementation Python implementation …
  7. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ How to use this? • Download the GraalVM package from GitHub and GO • can be used as a drop-in replacement for a JDK • plus contains packages for different languages (like JavaScript)
  8. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo
  9. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Community vs. Enterprise Edition • Community Edition is free to use (and open-source) • Enterprise Edition provides additional value • more performance optimizations • security enhancements • and more
  10. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What does it mean for the Eclipse IDE?
  11. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Running Eclipse • Download JDK11 • Enable GraalVM as JIT compiler • -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI • Run the IDE • uses the Graal compiler as the C2 JIT compiler • but you will probably not notice a meaningful difference
  12. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Running Eclipse • Download the GraalVM distribution • it looks like a regular JDK (contains many pieces from OpenJDK) • Run the IDE • works just fine as a drop-in replacement of the JDK • uses the GraalVM compiler as the C2 JIT compiler • but you will probably not notice a meaningful difference either
  13. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Native Images
  14. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Native Images in GraalVM • GraalVM is not the same as native images using AOT compilation • But you can use GraalVM to create native images for JVM-based languages
  15. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Why? • Super fast startup • Lower memory footprint
  16. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ How does that work? Your Java code JDK SubstrateVM Binary Compiled Code Initial Heap static analysis AOT compilation + snapshotting intermediate model
  17. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ SubstrateVM • Implements the missing pieces of the JVM in Java • Gets compiled into native code via the Graal compiler • Has many limitations: • closed world assumption (no dynamic classloading) • reflection needs to be pre-configured • resources need to be pre-configured • proxies supported, but statically generated (and for JDK proxies only) • No invokeDynamic or MethodHandles • limited garbage collection (very simple at the moment)
  18. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo
  19. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Running Eclipse IDE as native-image? • Would it be possible to compile the whole IDE as one big native image? • Probably not • everything is based on OSGi, which uses dynamic classloading • reflection is used all over the place • installing additional plugins not even possible • Closed-world assumption is not a good fit with the Eclipse IDE
  20. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ OSGi Connect - Project Atomos • Maybe this will open-up the door towards an Equinox implementation that could be compiled to a native image? • https://github.com/tjwatson/atomos/tree/master • Implements the OSGi Connect spec for various use cases, including a prototype for the SubstrateVM
  21. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What about Language Servers ? • fast startup would be nice • lower memory footprint would also be nice • peek performance not extremely important • Maybe a good candidate for native images?
  22. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot Language Server • Spring Boot application by itself, compiled to a native image using GraalVM and experimental Spring Boot support for GraalVM native images • early experiences • super fast startup • pretty good performance • But: • not a lot of fun to make it work
  23. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Startup time (ms) needed to startup language server to be ready to use JDK 11.0.4 Graal native image 0 550 1100 1650 2200
  24. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Example: ASTParser and type resolving • compiled as part of the native-image • pretty straight-forward • not a lot to configure for the native-image builder • But: • works for Java8 projects only • Java9 module file system loaded ad-hoc via newly created classloader from different JDKs (hard to fit this into the closed-world assumption)
  25. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Performance time (ms) needed to parse java source code using JDT JDK 11 / C1 Graal native image 0 950 1900 2850 3800
  26. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Conclusion
  27. Unless otherwise indicated, these slides are © 2013-2019 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Conclusion • Running Eclipse in top of GraalVM just runs fine • but doesn’t come with huge performance improvements • Language Servers seem to be a good fit for native images • benefit from super-fast startup and lower memory footprint a lot • could be created and shipped for various platform • (benefits from platform-specific fragments technology in Eclipse) • turning existing language servers into native images can be hard • libraries need to jump on the train and provide the necessary GraalVM native image config out-of-the-box