avatarYash Bansal

Summary

GraalVM significantly reduces application startup time through Ahead-of-Time (AOT) compilation, offering a performance boost and lower memory usage compared to traditional Just-in-Time (JIT) compilation on typical JVMs.

Abstract

The undefined website discusses the use of GraalVM, a high-performance virtual machine, to enhance application startup times. GraalVM, an open-source initiative by Oracle, employs AOT compilation to convert application code into native code before execution, contrasting with the JIT compilation method used by conventional JVMs. This AOT approach not only accelerates startup times but also leads to reduced memory consumption and improved overall performance. The website provides a demonstration comparing the startup times of a basic application running on JVM 8 and GraalVM, showing that GraalVM can be 3-4 times faster, with startup times as low as 10 ms compared to over 200 ms on JVM 8. Additionally, GraalVM's AOT compilation results in smaller binary sizes, which is particularly advantageous for mobile applications. The author, Yash Bansal, an Associate Principal Engineer at redBus, concludes that GraalVM's innovative AOT technology is a significant advancement for application performance and efficiency.

Opinions

  • The author believes that startup time is a critical metric for user experience and application success.
  • GraalVM's AOT compilation is presented as superior to JIT compilation in terms of startup time, memory usage, and performance.
  • The author emphasizes that the reduced memory usage from AOT compilation is especially beneficial for mobile applications.
  • The demonstration results are used to assert that GraalVM's startup time is significantly faster than that of JVM 8.
  • The author suggests that the performance improvements from using GraalVM are substantial enough to impact the success of an application positively.

Using GraalVM to reduce startup time

Comparison between typical JVM startup time to GraalVM time

What is GraalVM

GraalVM is a high-performance virtual machine that is designed to run applications written in various programming languages. It is an open-source project that was initiated by Oracle, and it provides a range of benefits to developers, including improved performance, reduced memory usage, and faster startup times.

What is Startup Time?

Startup time is the amount of time it takes for an application to launch and become functional. It is a critical metric that can impact user experience and determine the success of an application. The faster an application can start, the better it is for users, as it reduces the waiting time and enhances the overall performance.

How GraalVM Reduces Startup Time?

GraalVM uses a technology called Ahead-of-Time (AOT) compilation to reduce the startup time of applications. AOT compilation is a process where the application code is compiled into native code before it is executed. This approach is different from the traditional Just-in-Time (JIT) compilation used by most virtual machines, which compiles code at runtime.

Time for some DEMO….

Code being used —

Procedure :

JIT compilation(JVM 8) :

#Produces the class file javac BasicApp.java

#Run code /usr/bin/java BasicApp

AOT compilation(GraalVM) :

#Setting the ENV to GraalVM export PATH=”$PATH:/Users/$HOME_USER/graalvm-ce19/Contents/Home/bin” export GRAALVM_HOME=”/graalvm-ce-19/Contents/Home”

#Producing the binary file native-image — libc=musl -o basicApp BasicApp

#Run code time ./BasicApp

Results :

JIT compilation :

AOT compilation :

Result : GraalVM startup time + completion time is 3–4 times faster than JVM 8 startup + completion time.

Incase of GraalVM, the application code itself took most of the time to complete (44 milli-seconds), but the startup time is barely 10 ms. Now compare this with Java8 VM, which took just 33 milli-seconds to run the application code, and over 200 ms as the startup time.

Bonus Features :

Reduced Memory Usage

AOT compilation produces native code that can be loaded directly into memory, reducing the overall memory usage of the application. This can be beneficial for applications that run on mobile devices.

The above created binary executable for GraalVM is just 11MB in size, whereas A basic Java application which runs using JVM + JRE will be in 100s of MB.

Improved Performance

AOT-compiled code can be optimised for the target platform(macOS, Linux), resulting in better performance by taking advantage of hardware-specific features and optimisations that are not available to JIT-compiled code.

Conclusion

GraalVM provides an innovative solution to reduce startup time and improve application performance. Its AOT compilation technology eliminates the overhead associated with JIT compilation, resulting in faster startup times, reduced memory usage, and improved performance.

****************************************************************************

About the author :

Yash Bansal is an Associate Principal Engineer at redBus. More info about him can be found on his LinkedIn profile.

Graalvm
Graalvm Native Image
Java
Java21
Recommended from ReadMedium