GraalVM 22.1: Developer experience improvements, Apple Silicon builds, and more

Alina Yurenko
graalvm
Published in
8 min readApr 26, 2022

Today we’re releasing GraalVM 22.1! This release brings new features and lots of improvements — we’ll cover the highlights in this blog post.

This release includes JDK 11 and JDK 17-based builds. As always, you can download GraalVM Community from GitHub, and get the GraalVM Enterprise builds from OTN.

You can also install the latest version of GraalVM via the GraalVM Extension Pack for Java for VS Code or with Homebrew on macOS.

Now, let’s take a look at what’s in this new release!

Alternatively, check out the release stream replay:

Native Image

Over the last few releases we’ve done a lot of work to improve the developer experience of GraalVM Native Image: we’ve improved build times and memory requirements, introduced new build output, updated native build plugins, and more. Today we’re introducing another feature — a quick build mode for Native Image. Depending on the size and complexity of the application you’re compiling with Native Image, the build process can take significant time because GraalVM needs to analyze your entire application and its dependencies, and then optimize and compile all its reachable code. Such a thorough process is essential for Native Image and critical to ensure runtime performance, but it can be simplified for development purposes when you mostly want to ensure correct behavior and get quick results. With quick build mode enabled, the compiler works in economy mode with fewer optimizations, resulting in much faster compilation times.

We’ve measured the impact of quick build mode on the time it takes to compile the Graal compiler into the shared “libgraal” library that ships in GraalVM builds:

The impact of quick-build mode of Native Image

In quick build mode, the compilation stage of the build process is 81% faster! Which also results in a 43% speedup of the overall build time.

To enable quick build mode, add -Ob (capital “O”, lower case “b”) when you run the native-image utility. For example,

$ native-image -Ob HelloWorld

Please note that we only recommend quick build mode for development purposes because it optimizes build time at a cost of runtime performance and memory usage. For running in production, use the default compilation mode, which provides the best runtime performance and memory efficiency.

This is the first release to include quick build mode so we are looking for your feedback, issue reports, and suggestions. We’ll keep working on this mode in future releases; in particular, we plan to improve runtime performance and speed up other stages of the build process.

We’ve also improved build time and size. Thanks to performance improvements and memory footprint reduction of native-image, executable build times are now faster (independent of the new quick build mode). The following table shows the continual reduction of executable size and executable build time of Spring petclinic-jdbc over the past few releases of GraalVM. The numbers are measured on a developer laptop with Linux, AMD64, JDK 11, GraalVM Enterprise, and spring-native 0.10.3 (we used an old version of spring-native to allow comparisons with old versions of GraalVM):

Executable build times and size improvements

With GraalVM 22.1, the executable build process is now 26% faster than in 21.1 in the default mode, and 54% faster in quick build mode.

Conditional configuration, announced in GraalVM 21.3, can now be generated using GraalVM’s tracing agent. With this approach, a class configuration entry is applied only if a provided condition (such astypeReachable) is satisfied, making the configuration more precise and reducing the size of a native executable.

Moreover, the default behavior of native-image has further been aligned with the java command: by default, a build no longer fails if a class cannot be found on the classpath or module path. In some cases, this is desirable because an application may define different behavior if certain classes are not available. If such a class, however, is explicitly required at runtime, the native executable will now fail (for example, with a java.lang.NotClassDefFoundError). To prevent such scenarios, Native Image provides a new --link-at-build-time option that ensures the build process fails if all or some classes are not available at build time. This option can be used in two ways: without arguments, in which case all classes in the scope are required to be fully defined, or with arguments, for example, --link-at-build-time=foo.bar.Foobar,demo.myLibrary.Name,…, in which case the arguments should be fully qualified class names or package names.

Preview build for Apple Silicon

Support for Apple Silicon was one of the features most requested by the community and we’re happy to announce that as of the 22.1 release, GraalVM Community is now officially available on this platform!

The darwin-aarch64 builds contain the following components:

  • JVM with the Graal compiler
  • Native Image
  • JavaScript
  • Java on Truffle (Espresso)

Please note that this is a preview build so you can expect some changes in subsequent releases. If you run into any issues we would be grateful for your feedback.

Even though official builds are first released today, we have already received great feedback from the community for earlier developer builds!

https://github.com/oracle/graal/issues/2666#issuecomment-1079408924
https://spring.io/blog/2022/03/23/building-native-images-with-graalvm-and-spring-native-on-apple-s-m1-architecture

Python

In the Python runtime, we’ve added support for frozen modules, which makes start-to-REPL 30% faster and uses 40% less memory. This change means that frequently used modules are parsed and converted into bytecode and stored inside the binary. During startup, the runtime loads this bytecode directly, avoiding the overhead of loading and parsing source files from the filesystem.

We’ve also continued our usual compatibility work, improving support with such top PyPI packages as lxml, pytz, Pillow, urllib3, setuptools, pytest, twine, jinja2, and six.

Ruby

This release of TruffleRuby introduces full support for foreign exceptions. Foreign exceptions no longer translate to RuntimeError, but instead remain as foreign exceptions — see the documentation for how to handle them. Such exceptions are now fully integrated, have most methods of Exception, and can be rescued with rescue Polyglot::ForeignException or rescue foreign_meta_object.

For more updates, see the project changelog.

JavaScript

In this release of the JavaScript runtime, we’ve introduced experimental engine caching support for Node.js applications (a GraalVM Enterprise feature). Engine caching is intended to eliminate the warmup of programs running on Truffle languages, which comes from operations such as loading, parsing, profiling, and compilation. We’ve implemented several new ECMAScript features, including Temporal, Intl.NumberFormat v3, ArrayGrouping, Array Find from Last.

For more details, see the project changelog.

R

We’ve improved R graphical support. In addition to grid and grid-based packages such as ggplot2, GraalVM R now supports the base graphics package, which provides simple and convenient functions to quickly generate plots.

Plotting `plot(sin, -pi, 2*pi)` in FastR

Java on Truffle

This release adds several new HotSwap features, including support for changing the super class and implemented interfaces, support for ‘Move Field in Hierarchy’ refactoring where the state is preserved, and (turned on by default) changing fields and class access modifiers. Also, the Java on Truffle LLVM Java libraries are now available for macOS (previously they were only available for Linux), and can be installed using gu install espresso-llvm. With this change, you can now use Java on Truffle in more scenarios: directly in a Java program running on the JVM, and with multiple guest contexts in a Native Image application.

Tooling and Developer Experience

We’ve made it easier to install and use GraalVM Enterprise Edition for development purposes including GraalVM’s VS Code extension as well as CI/CD workflows. All you have to do when installing components using Graal Updater or in GraalVM Extension is provide your email address and accept the license. After that you’ll receive a token that can be used to download GraalVM EE components locally and on your build machines. We also added support for this to the GitHub Action for GraalVM.

Another update in the VS Code extension is that it now has a Native Image pane to provide easy configuration of dynamic features via the tracing agent:

the Native Image pane

Also, the VisualVM integration in VS Code now works without additional configuration: you can open VisualVM and start monitoring applications via the extension’s UI.

The GraalVM Tools for Micronaut extension now supports database development for various JDBC-accessible databases, including Oracle Autonomous Database. It provides functionality to register databases, create Micronaut @Entity and @Repository classes, as well as SQL Code Completion in Micronaut Data finders or @Query annotations, and easy debugging of database application.

Working with databases from the Micronaut extension

Truffle Language and Tool Implementations

One of the major changes in this release is the introduction of TruffleStrings. It’s an efficient implementation of a String type, which can be shared between Truffle languages. We encourage language implementers to use Truffle Strings as their language’s string type for easier interoperability and better performance. If you’re curious about how it’s different from java.lang.String, we provide some details in the TruffleStrings guide. Among GraalVM languages, we've already migrated JavaScript and Regex to use the new implementation. Expect more updates and optimizations in future releases.

Community

As always we are grateful to the community and our partners in the ecosystem for working with us on this release. There were many helpful reports and contributions on GitHub, and sharing feedback and helping other community members on GraalVM’s platforms helps us collectively make GraalVM better for everyone. In particular,

  • Native Image support for several new JFR events including SafepointBegin, SafepointEnd, GarbageCollection, GCPhasePause, and GCPhasePauseLevel were contributed by Red Hat;
  • A significant part of Ruby 3 keyword arguments support in TruffleRuby was contributed by Shopify’s engineering team;
  • The Apple Silicon support was implemented with a lot of community feedback and input.

Conclusion

Thanks to the GraalVM community for all the feedback, suggestions, and contributions that went into this release. If you have additional feedback on this release, or suggestions for features that you would like to see in future features, please share them with us on Slack, GitHub, or Twitter.

— the GraalVM team

--

--

Alina Yurenko
graalvm

I love all things tech & community. Developer Advocate for @graalvm, blog posts about programming, open source, and devrel.