BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News GraalVM for JDK 21 Delivers Performance Enhancements and Improved Developer Experience

GraalVM for JDK 21 Delivers Performance Enhancements and Improved Developer Experience

On the same day as the release of Java 21, Oracle announced the release of GraalVM for JDK 21. GraalVM is a JDK that uses an alternative just-in-time (JIT) compiler but it also includes a Native Image module, a technology that allows Java applications to run as native executables, without the need for a JVM. This can improve the performance of Java applications in terms of speed, memory, and size.

At Oracle, they compared the performance of Native Image with JIT compilation, which is the default mode of running Java applications on a JVM. JIT compiles Java bytecode into machine code at runtime. Using various benchmarks and metrics, the results show that Native Image achieves higher peak throughput, lower memory usage, faster startup time, and smaller packaging size than JIT.

The image below compares the results. The Spring Petclinic, a Java web application that simulates a veterinary clinic, was used as an example..

GraalVM Native Image outperformed JIT using Profile-Guided Optimizations (PGO), a technique that collects information about the application’s behavior during execution and uses it to optimize the native code, and the G1 Garbage Collector.

The new version of GraalVM also introduces a new application levels policy, the default command line parameter is -O2 which is quite aggressive and provides high performance, 10–15% faster compile times, and has been tuned for common Java microservice workloads. Now a new value is available, -O3, which applies maximum optimizations for the best performance. This level is automatically enabled when using PGO.

Oracle GraalVM introduces several enhancements to improve the developer experience in its latest release. Developers can now exercise more control over the build process with the new --parallelism option, enabling them to specify the number of threads used during builds. The build output has been upgraded to display memory and thread limits, and the output color can be customized using --color.

Memory management in the Native Image build process has been revamped. By default, it now prioritizes using free memory, switching to 85% of total memory if free memory falls below 8GB, preventing machine slowdowns. Developers can also utilize native-image-inspect to dump the heap of executables and shared libraries for debugging purposes.

Error handling is improved with specialized exceptions for missing metadata, resources, and serialization metadata, enhancing program stability. A new class initialization strategy allows all classes to be used and initialized at build time, irrespective of the class initialization configuration, and developers can enable this with --strict-image-heap.

Notably, the gu tool is no longer required for GraalVM and Native Image, streamlining the development process. Additionally, support for the JFR event, ThreadCPULoad, has been added.

Oracle GraalVM is distributed with the GraalVM Free Terms and Conditions (GFTC) license, which makes its advanced just-in-time (JIT) and ahead-of-time (AOT) compilation technology available to all developers.

About the Author

Rate this Article

Adoption
Style

BT