JAVA17’s GraalVM and HotSpot JVM showcase equally impressive performance feats - No one is a winner here
Have been reading quite a bit of references about GraalVM performance.
It's been suggested as the best performance VM for serverless, cloud and microservcies.
So I thought to give it a try and compare it's performance with Oracel Hotspot JVM.
About GraalVM
GraalVM is high performance JDK and JRE developed by Oracle to improve and enhance execution of java applications.
It's key features:
Graal compiler for advanced just-in-time compilations and dynamic optimizations.
Ahead of time(AOT) compilation to native image.
Multi language support and Polygot programming - supports multiple languages like javascript, ruby , Python.
Note: JIT and AOT features are not entirely new , these exist with open jdk and oracle jdk as well. Here, it's mentioned to be more enhanced and performance, resource efficient.
Installing Graal VM
Steps to install :
Download graalVM jdk17 from here.
Extract it
3. Move to path /opt/graalVm/
4. Set class paths
Switching to Graal VM
Now you need to switch to graalvm. For that use this command:
This will show you all java versions installed on your machine
Select '0' as that's the graalVM and check your java version:
Your graalVM should reflect as below:
Comparison of GraalVM with Oracle Hotspot JVM
Here we have , Average latency comparison for Spring boot api. I did it 3 times but did not find any improvement in performance.
Chart for latency comparison:
Same can be analysed from the chart below - both GraalVM and Oracle Hotspot JVM delivers similar latency for spring boot api / microservice.
Let's walk through resource utilization as well for both runtimes in JAVA 17.
CPU Utilization:
Looking as CPU utilization, we can only observe GraalVM taking 10% more CPU in initial time period.
GraalVM CPU utilization
Oracle Hotspot CPU utilization
Heap Utilization:
Heap utilization is also similar for both except slightly higher heap utilization peaks in GraalVM.
GraalVM Heap utilization
Oracle Hotspot Heap utilization
GC Performance:
Coming to GC analysis, although nothing to conclude but as observation:
Max pause is higher in GraalVM
But CPU time if lower in GraalVM
Conclusion
This quick endeavour to test the waters doesn't find anyone as clear winner. Both JAVA 17 runtime environments delivers similar latency and resource utilization as well.