GraalVM for Java developers

A presentation at Spring I/O in May 2019 in Barcelona, Spain by Oleg Šelajev

Slide 1

Slide 1

for Java developers Oleg Šelajev GraalVM team, Oracle Labs @shelajev Copyright © 2019, Oracle and/or its affiliates. All rights reserved.

Slide 2

Slide 2

Safe Harbor Statement The following is intended to provide some insight into a line of research in Oracle Labs. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described in connection with any Oracle product or service remains at the sole discretion of Oracle. Any views expressed in this presentation are my own and do not necessarily reflect the views of Oracle. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 2

Slide 3

Slide 3

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !3

Slide 4

Slide 4

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !4

Slide 5

Slide 5

Why GraalVM? Fast Java, Scala, Kotlin, Groovy, Clojure… Instant startup, low footprint Polyglot & embeddable VM Interoperability between languages: node.js, Python, Ruby, R Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !5

Slide 6

Slide 6

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !6

Slide 7

Slide 7

GraalVM Compiler Java HotSpot VM Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !7

Slide 8

Slide 8

LLVM Truffle Framework GraalVM Compiler Java HotSpot VM Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !8

Slide 9

Slide 9

Copyright © 2019, Oracle and/or its affiliates. All rights reserved.

Slide 10

Slide 10

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !10

Slide 11

Slide 11

Launching earlier this month: GraalVM Enterprise 19.0 • More performance • Smaller footprint • Managed runtime for better isolation when running native code • Oracle Enterprise Support 7x24x365 Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 11

Slide 12

Slide 12

Copyright © 2019, Oracle and/or its affiliates. All rights reserved.

Slide 13

Slide 13

Renaissance suite https://renaissance.dev Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !13

Slide 14

Slide 14

Streams API example benchmarks https://medium.com/graalvm/stream-api-performance-with-graalvm-be6cfe7fbb52 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !14

Slide 15

Slide 15

sbt > clean; compile; https://medium.com/graalvm/compiling-scala-faster-with-graalvm-86c5c0857fa3 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !15

Slide 16

Slide 16

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !16

Slide 17

Slide 17

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !17

Slide 18

Slide 18

Matrix multiplication https://www.youtube.com/watch?v=RFF2SfPMfpk Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !18

Slide 19

Slide 19

Matrix multiplication valhallaBench.Multiply.multiply (lower is better) (size) Mode Cnt valhallaBench.Multiply.multiply 100 avgt 3 JDK11 + Graal (size) Mode Cnt valhallaBench.Multiply.multiply 100 avgt 3 GraalVM EE 1.0-rc8 (size) Mode Cnt valhallaBench.Multiply.multiply 100 avgt 3 JDK 11 Score 7944.935 Error ± Score 3450.944 Error ± 2.3x Score 3134.066 1963.931 ± Units us/op Units 1130.123 us/op Error Units 518.812 us/op 2.5x Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !19

Slide 20

Slide 20

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !20

Slide 21

Slide 21

https://twitter.com/janiszt/status/1091678397523283968

Slide 22

Slide 22

New in GraalVM 19: libgraal Use Native-Image to compile the GraalVM compiler and link in HotSpot • Faster startup • No profile pollution • Separate heap for the compiler libgraal previous setup 22

Slide 23

Slide 23

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !23

Slide 24

Slide 24

Copyright © 2019, Oracle and/or its affiliates. All rights reserved.

Slide 25

Slide 25

ECMAScript 6 compatibility Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !25

Slide 26

Slide 26

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !26

Slide 27

Slide 27

Graal.js on JDK11 https://github.com/graalvm/graal-js-jdk11-maven-demo Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !27

Slide 28

Slide 28

https://www.youtube.com/watch?v=mRKjWrNJ8DI Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !28

Slide 29

Slide 29

https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !29

Slide 30

Slide 30

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !30

Slide 31

Slide 31

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !31

Slide 32

Slide 32

https://medium.com/graalvm/analyzing-the-heap-of-graalvm-polyglot-applications-b9963e68a6a Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !32

Slide 33

Slide 33

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !33

Slide 34

Slide 34

GraalVM native images Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !34

Slide 35

Slide 35

Native images • Full AOT compilation to machine code • Works with memory management • Secure execution (e.g., bounds checks) • Embeddable with native applications Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !35

Slide 36

Slide 36

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !36

Slide 37

Slide 37

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !37

Slide 38

Slide 38

New in GraalVM 19: native-image trace agent Previously, to use Native Image with reflection*, you needed a configuration file You could build it by hand, or use a framework to generate it Now, you can profile any running program in HotSpot to generate a configuration file for native image You can run it multiple times to exhaust all of the reflective test paths (proxies, JNI, reflection) $JAVA_HOME/bin/java -agentlib:nativeimage-agent=config-output-dir=META-INF/ native-image/ HelloReflection foo bar

Slide 39

Slide 39

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !39

Slide 40

Slide 40

https://github.com/spring-projects/spring-framework/wiki/GraalVM-native-image-support Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !40

Slide 41

Slide 41

Work in progress Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !41

Slide 42

Slide 42

https://medium.com/graalvm/safe-and-sandboxed-execution-of-native-code-f6096b35c360 Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !42

Slide 43

Slide 43

High performance, polyglot, language-level virtualization layer… embeddable across the stack in native and JVM-based applications. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !43

Slide 44

Slide 44

Why GraalVM? Fast Java, Scala, Kotlin, Groovy, Clojure… Instant startup, low footprint Polyglot & embeddable VM Interoperability between languages: node.js, Python, Ruby, R Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !44