Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
Run programs faster
everywhere 
Oleg Šelajev
GraalVM team, Oracle Labs
@shelajev
Copyright © 2019, Oracle and/or its affiliates. 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 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.
2
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !3
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !4
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !5
Fast Java, Scala, Kotlin, Groovy, Clojure...
Instant startup, low footprint
Polyglot & embeddable VM
Interoperability between languages: node.js, Python, Ruby, R
Why GraalVM?
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !6
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !7
Java HotSpot VM
GraalVM Compiler
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !8
Java HotSpot VM
GraalVM Compiler
Truffle Framework
LLVM
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !10
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 11
• More performance
• Smaller footprint
• Managed runtime for better
isolation when running native code
• Oracle Enterprise Support 7x24x365
Launching earlier this month:

GraalVM Enterprise 19.0
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !13
Renaissance suite
https://renaissance.dev
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !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. !15
sbt > clean; compile;
https://medium.com/graalvm/compiling-scala-faster-with-graalvm-86c5c0857fa3
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !16
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !17
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !18
Matrix multiplication
https://www.youtube.com/watch?v=RFF2SfPMfpk
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !19
valhallaBench.Multiply.multiply (lower is better)
JDK 11 (size) Mode Cnt Score Error Units
valhallaBench.Multiply.multiply 100 avgt 3 7944.935 ± 1963.931 us/op
JDK11 + Graal (size) Mode Cnt Score Error Units
valhallaBench.Multiply.multiply 100 avgt 3 3450.944 ± 1130.123 us/op
GraalVM EE 1.0-rc8 (size) Mode Cnt Score Error Units
valhallaBench.Multiply.multiply 100 avgt 3 3134.066 ± 518.812 us/op
Matrix multiplication
2.3x
2.5x
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !20
https://twitter.com/janiszt/status/1091678397523283968
22
libgraal previous setup
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
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !23
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !25
ECMAScript 6 compatibility
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !26
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !27
Graal.js on JDK11
https://github.com/graalvm/graal-js-jdk11-maven-demo
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !28
https://www.youtube.com/watch?v=mRKjWrNJ8DI
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !29
https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !30
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !31
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !32
https://medium.com/graalvm/analyzing-the-heap-of-graalvm-polyglot-applications-b9963e68a6a
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !33
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !34
GraalVM native images
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !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. !36
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !37
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)
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
$JAVA_HOME/bin/java -agentlib:native-
image-agent=config-output-dir=META-INF/
native-image/ HelloReflection foo bar

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !39
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !40
Work in progress
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | !41
https://medium.com/graalvm/safe-and-sandboxed-execution-of-native-code-f6096b35c360
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. !42
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
Fast Java, Scala, Kotlin, Groovy, Clojure...
Instant startup, low footprint
Polyglot & embeddable VM
Interoperability between languages: node.js, Python, Ruby, R
Why GraalVM?

GraalVM: Run Programs Faster Everywhere

  • 1.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. Run programs faster everywhere  Oleg Šelajev GraalVM team, Oracle Labs @shelajev
  • 2.
    Copyright © 2019,Oracle and/or its affiliates. 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 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. 2
  • 3.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !3
  • 4.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !4
  • 5.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !5 Fast Java, Scala, Kotlin, Groovy, Clojure... Instant startup, low footprint Polyglot & embeddable VM Interoperability between languages: node.js, Python, Ruby, R Why GraalVM?
  • 6.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !6
  • 7.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !7 Java HotSpot VM GraalVM Compiler
  • 8.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !8 Java HotSpot VM GraalVM Compiler Truffle Framework LLVM
  • 9.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved.
  • 10.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !10
  • 11.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 11 • More performance • Smaller footprint • Managed runtime for better isolation when running native code • Oracle Enterprise Support 7x24x365 Launching earlier this month:
 GraalVM Enterprise 19.0
  • 12.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved.
  • 13.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !13 Renaissance suite https://renaissance.dev
  • 14.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !14 Streams API example benchmarks https://medium.com/graalvm/stream-api-performance-with-graalvm-be6cfe7fbb52
  • 15.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !15 sbt > clean; compile; https://medium.com/graalvm/compiling-scala-faster-with-graalvm-86c5c0857fa3
  • 16.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !16
  • 17.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !17
  • 18.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !18 Matrix multiplication https://www.youtube.com/watch?v=RFF2SfPMfpk
  • 19.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !19 valhallaBench.Multiply.multiply (lower is better) JDK 11 (size) Mode Cnt Score Error Units valhallaBench.Multiply.multiply 100 avgt 3 7944.935 ± 1963.931 us/op JDK11 + Graal (size) Mode Cnt Score Error Units valhallaBench.Multiply.multiply 100 avgt 3 3450.944 ± 1130.123 us/op GraalVM EE 1.0-rc8 (size) Mode Cnt Score Error Units valhallaBench.Multiply.multiply 100 avgt 3 3134.066 ± 518.812 us/op Matrix multiplication 2.3x 2.5x
  • 20.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !20
  • 21.
  • 22.
    22 libgraal previous setup Newin 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
  • 23.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !23
  • 24.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved.
  • 25.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !25 ECMAScript 6 compatibility
  • 26.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !26
  • 27.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !27 Graal.js on JDK11 https://github.com/graalvm/graal-js-jdk11-maven-demo
  • 28.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !28 https://www.youtube.com/watch?v=mRKjWrNJ8DI
  • 29.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !29 https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb
  • 30.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !30
  • 31.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !31
  • 32.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !32 https://medium.com/graalvm/analyzing-the-heap-of-graalvm-polyglot-applications-b9963e68a6a
  • 33.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !33
  • 34.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !34 GraalVM native images
  • 35.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !35 Native images • Full AOT compilation to machine code • Works with memory management • Secure execution (e.g., bounds checks) • Embeddable with native applications
  • 36.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !36
  • 37.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !37
  • 38.
    Now, you canprofile 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) 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 $JAVA_HOME/bin/java -agentlib:native- image-agent=config-output-dir=META-INF/ native-image/ HelloReflection foo bar

  • 39.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !39
  • 40.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !40 Work in progress
  • 41.
    Copyright © 2018,Oracle and/or its affiliates. All rights reserved. | !41 https://medium.com/graalvm/safe-and-sandboxed-execution-of-native-code-f6096b35c360
  • 42.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !42 High performance, polyglot, language-level virtualization layer… embeddable across the stack in native and JVM-based applications.
  • 43.
    Copyright © 2019,Oracle and/or its affiliates. All rights reserved. !43 Fast Java, Scala, Kotlin, Groovy, Clojure... Instant startup, low footprint Polyglot & embeddable VM Interoperability between languages: node.js, Python, Ruby, R Why GraalVM?