Wednesday, October 12, 2022

GraalVM Enterprise 22.2—Lower memory, smaller downloads, simpler library usage

GraalVM Enterprise 22.2, Oracle Java Prep, Oracle Java Certification, Oracle Java Career, Oracle Java Tutorial and Materials, Oracle Java Certification

The GraalVM Enterprise 22.2 release includes much anticipated Apple M1 support, a significant reduction in the memory requirements of Native Image, a smaller base JDK distribution package, and an exciting new facility to make it easier to use third-party libraries in your Native Image compiled applications.

Apple Silicon M1/M2


If you don't already have an Apple silicon M1/M2 laptop you're probably thinking about joining the many developers who have raved about its excellent performance, low power consumption, and typically silent operation.  Developers who do have one can now try out GraalVM Enterprise 22.2's new experimental support for Apple silicon and see what the combination of cutting-edge hardware and advanced compiler technology can do!  Running GraalVM Enterprise Native Image on Apple silicon is significantly faster than on Intel Macs improving day-to-day developer productivity.

Slimmed Down JDK


In addition to core Java support, GraalVM Enterprise provides many optionally installable packages supporting several programming languages including Python, Ruby, and R.  To make it easier for developers to get just the components they need we've streamlined the base GraalVM Enterprise installation bundle so that it is smaller and more modular.  You can now download just the GraalVM Enterprise JDK to run Java applications on the JVM.  The reduction in size is immediately visible in the download packages.  For example, in the previous 22.1 release the core Linux amd64 download was 518 MB.  In 22.2 the new JDK download for the same OS and architecture is only 217 MB, a reduction of almost 60%!  Being able to download just the JDK is especially useful if you're deploying your Java app in a container where it's important to keep image size low.  If you do want to use Native Image, VisualVM, or any of the GraalVM supported languages, it's easy to install those components on top of the base JDK.  The choice is yours.

Lower Memory Requirements


With every release, GraalVM Native Image get faster, smarter, and leaner.  In the recent past, 21.3 achieved performance on par with the JVM, 22.0 introduced much more user friendly output, 22.1 delivered faster compilations and a new quick build mode to improve the developer experience.  Now in 22.2 Native Image has cut its memory needs in half!  GraalVM Native Image is written in Java and typically more memory for a Java app leads to better performance.  Most developer machines have plenty, but CI/CD build machines (runners) tend to be more constrained.  For example, free GitHub Actions are limited to 7GB and Oracle Cloud Infrastructure DevOps runners are (currently) limited to 8GB.  With the 22.2 release, GraalVM Native Image can be used on both of those CI/CD platforms to successfully build applications without encountering an out-of-memory error.  Of course, you could always pay for bigger build runners, but thanks to lower memory requirements, GraalVM Enterprise 22.2 can help keep your costs down!

Third-Party Libraries and Native Image


GraalVM Native Image takes a closed-world approach to determine what classes, methods, and fields are compiled into a native executable.  Starting from your application entry point, Native Image performs static analysis to determine all the reachable code that needs to be included.  Unreachable code is excluded from the generated native executable.  This is great in general and the approach works very well with modern frameworks such as Micronaut.  However, many libraries and frameworks use dynamic Java features (such as reflection) that obscure code paths from static analysis.  For such libraries it's necessary to provide Native Image with additional reachability metadata to ensure all required code is included in the final executable.

In GraalVM 22.2, to make it easier to use popular libraries that require additional reachability metadata, the Oracle GraalVM team in conjunction with the Spring and Quarkus teams have created a GitHub repository where metadata for popular libraries can be published.  Using this metadata is as easy as setting a property in the GraalVM Native Build Tools Maven or Gradle plugins.  For example, in Gradle you can enable use of the reachability metadata repository with:

graalvmNative {
    metadataRepository {
        enabled = true
    }
}

For more details, see the Maven and Gradle plugin guides and try out an example.

Wrapping Up


Release to release, GraalVM Enterprise delivers additional performance optimizations and improvements in Native Image compilation time, generated executable size, and developer productivity.  For a complete list of all the changes in GraalVM 22.2 browse the release notes.

GraalVM Enterprise is included in the Oracle Java SE Subscription and is available at no additional cost for use on Oracle Cloud Infrastructure. Download the latest release today!

Source: oracle.com

Related Posts

0 comments:

Post a Comment