GraalVM Features and Future
In this article, look into the GraalVM’s evolution and prospects to understand why you will benefit from integrating the technology in production.
Join the DZone community and get the full member experience.Join For Free
GraalVM, as the name suggests, represents the Holy Grail of modern cloud-native development by boosting the performance of Java applications and, at the same time, making highly efficient and seamless polyglot programming a reality. But what exactly lies behind these claims? In this article, we will look into the platform’s evolution and prospects to understand why you will benefit from integrating the technology in production. We will also summarize the key aspects of GraalVM licensing, including the new license introduced by Oracle in 2023.
Benefits of GraalVM for Java Development
GraalVM is a platform based on Java HotSpot VM implemented in Java. It includes the Java Development Kit (JDK), the advanced just-in-time compiler, the ahead-of-time compiler, and tools for adding programming languages to the project. Its goal is accelerating JVM-based applications and providing a foundation for multilingual programming. The benefits of the technology for Java developers can be summarized as follows:
- An enhanced JIT compiler written purely in Java increases the performance of applications compared to traditional HotSpot C1/C2 compilers.
- The AOT compilation (Native Image) allows for the transformation of JVM-based apps into native images with almost instant startup, thus eliminating the notorious warmup of Java programs.
Native Image helps to optimize memory footprint and provides instant startup, which is crucial for some use cases (for example, Lambda Functions). But even if the application is hard to migrate to Native Image, programmers can still use GraalVM to boost throughput and take their microservices to the next level, where each service uses the capabilities of various programming languages for specific tasks.
Notable GraalVM Improvements in Recent Releases
GraalVM is a rapidly evolving technology. There were dozens of features and hundreds of enhancements introduced into GraalVM CE since the first release in 2019. The changes concern the Native Image technology and language frameworks. It would be impossible to list all of them in one article, so below are just a few improvements made for Native Image and Java that demonstrate the project progression within the latest releases:
- Native Image is now shipped as part of GraalVM (for JDK 20), so there is no need to install it with the gu install native-image command.
- The expansion of supported platforms and system configurations: the technology works on x64 and AArch64 with Linux and macOS and on x64 with Windows. The Docker container images are also available on GitHub to support container-based development.
- Java developers can now use GraalVM Reachability Metadata Repository, which contains the metadata on the most popular Java libraries and frameworks that do not support GraalVM Native Image by default yet. The repository enables users to minimize errors at run time.
- Memory consumption is being continuously improved. For instance, the size of the base GraalVM binary was reduced by 42% in version 22.2.0. The June 2023 release boasts a better memory footprint of the Native Image build process, reducing the risk of out-of-memory errors and using available resources more efficiently.
- Added support of AWT and Swing toolkits for developing GUI applications.
In addition, GraalVM is always based on the latest OpenJDK version with bug fixes and security patches, so paying attention to the quarterly CPU releases is recommended to keep the development environment safe.
GraalVM currently uses SerialGC and EpsilonGC in Community Edition. Oracle GraalVM also ships G1GC (more information on these releases is provided in the section below). SerialGC works in one thread and freezes all application threads until it completes the collection, thus increasing latency. To reduce pause times, it was decided to implement the ParallelGC to GraalVM CE. The new collector is based on the SerialGC code but utilizes several threads to parallelize its work.
The new ParallelGC uses one thread per CPU core by default (max. eight threads per core) to perform the garbage collection. The number of threads can be regulated with the -XX: ParallelGCThreads option. As garbage collection is done in several phases, the phase computing transitive closure was parallelized first, but plans include parallelization of more GC phases.
The BellSoft engineers, who took an active part in developing and integrating the new collector, measured its performance with the HyperAlloc benchmark aimed at simulating the application characteristics that affect the GC latency. The results demonstrated a decrease in GC pause times by 10–40%.
Currently, the ParallelGC is implemented in Liberica Native Image Kit as an experimental feature. After receiving feedback from the community and validating its performance, the engineers will integrate it into the main GraalVM CE branch.
GraalVM CE vs Oracle GraalVM and a New Oracle License
Up until June 2023, there were two GraalVM distributions available: GraalVM Community Edition (CE) based on OpenJDK and GraalVM Enterprise Edition (EE) based on Oracle JDK. But this year, Oracle has changed the licensing terms for GraalVM. Starting with the June 2023 release, a new GraalVM distribution is available for JDK 17 and JDK 20 instead of EE, which is Oracle GraalVM.
GraalVM EE, still available for 19 to 22 GraalVM versions, is distributed under My Oracle Support for commercial customers and OTN for GraalVM EE Including License for Early Adopter Versions for Personal, Development, and other Users.
Oracle GraalVM is distributed under the new GraalVM Free Terms and Conditions (GFTC) including License for Early Adopter Versions that permits free personal and commercial use. The license allows the developers to use the program for internal business operations and redistribute the unmodified program without charging any fees for this distribution, including fees for products that include or are bundled with a copy of the program. What are Early Adopter Versions? These product versions are continuously developed and modified so that future releases may contain features and changes incompatible with previous versions.
On the other hand, GraalVM CE (or GraalVM Open Source) is open-source software built from GitHub sources and licensed under GPLv2 + Classpath Exception. GPLv2 + CPE is a free software license enabling developers to modify and freely distribute the product’s source code. Still, at the same time, it gives them the right to add modules or libraries to the classpath that you can distribute under other licensing conditions.
The table below summarizes GraalVM versions and licenses:
As far as the support is concerned, GraalVM is a community-driven project, and there are various channels for getting help:
- GitHub repositories (where developers can report bugs)
- The Slack channel with GraalVM engineers
- The mailing list
Companies with Oracle’s Java SE subscription receive enterprise support for GraalVM within the bounds of their subscription. It is also possible to receive support from other vendors of GraalVM distributions. For example, BellSoft offers enterprise support for the Native Image technology as part of Liberica Native Image Kit, a GraalVM CE-based native-image compiler.
What about the features? The GraalVM community works on developing GraalVM CE under the auspices of the GraalVM Project Advisory Board, which includes representatives of major organizations: Oracle, VMWare, BellSoft, Red Hat, and so on. At the same time, Oracle works separately on Oracle GraalVM.
For the most part, Oracle GraalVM and GraalVM CE offer similar functionality with a few variations yet to be ported to the Community Edition. For instance, Oracle GraalVM Native Image includes G1 GC, Machine Learning (ML) based profile inference, and Profile-Guided Optimizations, which are absent in GraalVM CE.
Conclusion and Future Plans
The main development trends within the project concern the further enhancement of Native Image and significant convergence with the JDK, i.e., the alignment of the code base, features, APIs, and growth strategies. One of the steps towards this alignment is the introduction of the Galahad project in 2022, aimed at contributing Java-related GraalVM technologies to OpenJDK.
GraalVM is used in production by prominent companies such as Twitter, Facebook, Alibaba, and many others. In addition, it is natively supported in major Java frameworks: Spring Boot, Quarkus, Micronaut, and Helidon. The interest of industry leaders in GraalVM gives us the right to expect broader adoption of the technology in the near future.
Opinions expressed by DZone contributors are their own.