Slide 1

Slide 1 text

What GraalVM means for the Eclipse IDE Martin Lippert (Pivotal, @martinlippert)

Slide 2

Slide 2 text

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?

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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 …

Slide 8

Slide 8 text

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)

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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?

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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)

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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?

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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)

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Stay Connected. [email protected] #springone @s1p