GraalVM speeds up native image builds

GraalVM’s quick build mode for Native Image slashes builds times, but is recommended for development purposes only.

GraalVM 22.1, the latest release of the Oracle-built polyglot runtime, features an early iteration of quick build mode for Native Image, the platform’s technology for ahead-of-time (AOT) compilation of Java code into a standalone executable.

GraalVM 22.1 was introduced April 26. With quick build mode, the compiler works in economy mode with fewer optimizations, resulting in much faster compilation times. Native Image AOT-compiles Java code to a standalone executable, known as a native image. Depending on the size and complexity of the application being compiled, the build process can take significant time, with GraalVM having to analyze and optimize an entire application and its dependencies. The developers of GraalVM found that quick build mode resulted in an 43% improvement in the overall build time.

Quick build mode is only recommended for development purposes because it optimizes build time at the expense of runtime performance and memory usage. For production, developers should use the default compilation mode. Plans call for more work to be done to quick build mode to improve runtime performance and speed up other build stage processes. Executable build times also are faster in GraalVM 22.1, thanks to performance improvements and memory footprint reduction of native-image.

GraalVM Community Edition can be downloaded from GitHub. GraalVM Enterprise builds can be downloaded from Oracle Technology Network.

Other new features and improvementsin GraalVM 22.1:

  • GraalVM Community Edition is available for Apple Silicon in preview form.
  • Default behavior of native-image has further been aligned with the java command. A build no longer fails if a class cannot be found on the classpath or module path. This can be desirable because an application may define different behavior if certain classes are not available.
  • Conditional reflection configuration for Native Image, in which a class configuration entry is applied only if a provided condition is satisfied, now can be generated via a tracing agent. With conditional reflection configuration, a class configuration entry is applied only if a provided condition, such as typeReachable, is satisfied, making the configuration more precise and reducing the size of the executable.
  • Experimental engine caching is supported for Node.js applications in GraalVM Enterprise Edition.
  • The Python runtime adds support for frozen modules, which makes start-to-REPL 30% faster and uses 40% less memory. The change means frequently used modules are parsed, converted into bytecode, and stored inside the binary. During startup, the runtime loads this bytecode directly, avoiding overhead.

Copyright © 2022 IDG Communications, Inc.