What is GraalVM?
GraalVM is a tool for developers to write and execute Java code. Specifically, GraalVM is a Java Virtual Machine (JVM) and Java Development Kit (JDK) created by Oracle. It is a high-performance runtime that provides improvements in application performance and efficiency.
The goals of GraalVM include: writing a compiler that is faster and easier to maintain, improving the performance of languages that run on the JVM, reducing application startup times, integrating multi-language support into the Java ecosystem, as well as providing a set of programming tools to do so.
GraalVM adds an optimizing compiler to the JDK, which provides performance optimizations for individual languages and interoperability for polyglot applications. Besides supporting Java code, GraalVM also supports additional programming languages including Scala, Kotlin, Groovy, Clojure, R, Python, JavaScript, Ruby. Essentially, GraalVM allows developers to run code efficiently in multiple languages and libraries while in a single application.
Components of GraalVM
Among others, three components make up the core of GraalVM: a high performance optimizing just-in-time compiler, an ahead-of-time compiler to build native executables, and support for multiple languages.
More specifically, the components of GraalVM Enterprise include:
- The GraalVM compiler. A just-in-time compiler.
- Ahead of time compiler.Used to compile JVM-based applications to natively executable binaries.
- Support for multiple languages through Language ImplementationProvides the ability to implement language interpreters. This allows GraalVM to be expanded to add additional languages to the Java ecosystem. It also supports tools such as a language-agnostic debugger, profiler and heap viewer.
- 24x7 Oracle Premiere Support (MOS)
How does GraalVM work?
The GrallVM just-in-time compiler is used to accelerate performance of any Java and JVM-based application without the need for code changes. Grall VM can also use its ahead-of-time native image compiler to translate Java and JVM applications into native platform executables. The Enterprise version compiler includes 62 compiler optimization algorithms, also called phases. Of these algorithms, some include techniques for vectorizing complex programs, code specialization and large-scale escape analysis. Compiler phases are optimized through the use of techniques such as aggressive and polymorphic inlining.
Object allocations are also improved through optimizations made in memory-allocation. For example, GrallVM will use partial escape analysis and scalar replacement6 for such tasks. In general, GraalVM can achieve better performance with less memory.
Potential attack surfaces are also minimized when the ahead-of-time compiler compiles Java code into a native executable. This is because only the code required to execute the application is included. To do this, GrallVM will analyze the application code, its dependencies, dependent JDK libraries and VM components.
GraalVM Installation
GraalVM 20 has two different offerings: a Community Edition and Enterprise Edition. Both editions are designed to work for Windows, Linux and macOS platforms and on x86 64-bit systems. GraalVM is based on either JDK 8 or 11.
GraalVM also comes packaged with JavaScript and a package manager. The package manager, called gu, lets users install other languages. These components can be downloaded from GitHub or from Oracle directly.
Along with current versions of GraalVM that are available for download, new versions are currently being worked on, and are available for testing on GitHub.
GraalVM pricing
Pricing for GraalVM depends on the edition being used. The Community Edition is open sourced. This edition is built from sources available on GitHub. GraalVM Enterprise is available from Oracle under the Oracle GraalVM OTN License Agreement and under the Oracle Master Licence Agreement. The price of the enterprise edition may vary depending on the license.
Under the Oracle Master License Agreement, GraalVM Enterprise must be purchased for production use. The price of GraalVM Enterprise may vary depending on the license. Specifically, subscription prices will depend on the subscription metric and volume -- for example, the number of processors used. Under the OTN terms, GraalVM Enterprise is free for evaluation, testing and for developing nonproduction applications.
History of GraalVM
The word “Graal” comes from old French for “Grail.” The “Graal” Oracle project started out as a research project inside Oracle Labs, attempting to make a Java compiler while being fast and easy to maintain. The “VM” in “GraalVM” comes from the fact that it runs inside the JVM.
The research expanded to include the ability to perform Just-in-Time and Ahead-of-Time (AOT) compilation. This AOT capability is called a Native Image. As the project grew, the research expanded to include the ability to build interpreters for other non-JVM languages, like Python, Ruby and WebAssembly. This became the Language Implementation Framework.
The first production-ready version of GraalVM Enterprise was version 19.0, announced and released by Oracle in May 2019. In February 2020, GraalVM Enterprise 20.0.0 was released. This version focused on improving its support for Windows systems, as well as introduced an enhanced native-image tool and improved the tooling support. Changes were also made to the compiler and the supported languages.