Go Green with GraalVM

Amitpal Singh Dhillon
4 min readApr 22, 2021

As we celebrate Earth Day, let's consider how to improve environmental performance while creating business value by using GraalVM Enterprise, an energy-saving multilingual compiler. This has a significant impact on electricity costs, cooling costs, and possibly a reduction of server farm size while improving application performance.

There are global sustainability efforts underway, e.g. Singapore to launch a multi-ministry Green Plan to tackle climate change challenges, this includes new infrastructure investments and Oracle helping dozens of U.S. utilities that have committed to decarbonizing by 80% or more by 2050, clean cloud, and energy-saving software.

Architecture

Now, let's have a look at the architecture that is already making this possible. IT Workloads using GraalVM in the traditional JIT (Just-in-time) model which is akin to fuel versus a more energy-efficient AOT (Ahead-of-time) model.

GraalVM is an energy-efficient and multilingual software compiler that can run Just-in-time (JIT) and Ahead-of-time (AOT)
Diagram: An Energy Saving, Multilingual Compiler that can run in JIT and AOT

You want a fast startup when you have microservices and want to react to load spikes. But keeping warmed-up instances of virtual machines around — just like idling a car engine — uses energy-draining CPU cycles and expensive dynamic random-access memory.

Test Data: Before (JIT) vs After (AOT)

We conducted a series of tests using mixed workloads, e.g. an application written in Java and JavaScript that lists the files recursively in a directory on the machine (using Lambda Expressions and Streams API) while walking to a specific depth. Here are the results comparing the metrics to show the improvement in energy efficiency.

Table: Comparing results of JIT vs AOT for mixed Java and JavaScript workloads
Amitpals-MacBook-Pro:native-list-dir adhillon$ $GRAALVM_HOME/bin/native-image --language:js ExtListDir[extlistdir:60548]    classlist:   5,575.81 ms,  0.96 GB [extlistdir:60548]        (cap):   1,916.23 ms,  0.96 GB [extlistdir:60548]        setup:   6,816.32 ms,  0.96 GB [extlistdir:60548]     (clinit):   2,104.05 ms,  6.00 GB [extlistdir:60548]   (typeflow):  90,816.71 ms,  6.00 GB [extlistdir:60548]    (objects):  33,078.60 ms,  6.00 GB [extlistdir:60548]   (features):  10,460.53 ms,  6.00 GB [extlistdir:60548]     analysis: 140,946.37 ms,  6.00 GB [extlistdir:60548]     universe:   3,415.01 ms,  6.00 GB 
10115 method(s) included for runtime compilation [extlistdir:60548] (parse): 23,633.50 ms, 5.89 GB [extlistdir:60548] (inline): 11,617.99 ms, 5.70 GB [extlistdir:60548] (compile): 263,791.91 ms, 5.77 GB [extlistdir:60548] compile: 316,088.14 ms, 5.77 GB [extlistdir:60548] image: 24,160.61 ms, 5.78 GB [extlistdir:60548] write: 5,842.55 ms, 5.83 GB [extlistdir:60548] [total]: 507,171.52 ms, 5.83 GB
Amitpals-MacBook-Pro:native-list-dir adhillon$ time ./extlistdir $1Walking path: .. Total: 251 files, total size = 154326621 bytes

Summary

Based on the analysis above we could conclude that energy efficiency improved by ~25% with AOT versus JIT while running the same workload over the same duration (time) on the same machine. AOT helps us go green at the cloud-native edge with superior performance (fast startup, low memory footprint) and enhanced environmental sustainability. Continuous research in speed, intelligence, and leaner runtimes has a positive sustainable impact on the whole software industry making it a default choice for the future.

Back to the Future

Explore the possibilities of Autonomous Driving with the combination of Micronaut and GraalVM. Self-driving Autonomous vehicles exposing REST endpoints for a remote-control UI and the ability to control the car’s throttle and steering. This could pave the way for cloud-native software that is energy-aware by default.

Autonomous Self Driving Cars with GraalVM + Micronaut

References

Workload: https://github.com/graalvm/graalvm-demos/blob/master/native-list-dir/ExtListDir.java

Software-based Energy Management: https://software.intel.com/content/www/us/en/develop/articles/intel-power-gadget.html

National Grid Utility with Zero Carbon targets https://www.greentechmedia.com/articles/read/oracle-national-grid-utility-zero-carbon-targets

Twitter is a massively distributed system with thousands of machines running thousands of JVMs. In any similar big system, a small change in performance and CPU utilization is multiplied thousandfold and results in big savings. Electricity costs, cooling costs, and possibly a reduction of server farm size. https://www.forbes.com/sites/oracle/2019/05/08/meet-the-team-that-built-graalvm-an-energy-saving-multilingual-compiler-written-entirely-in-java/

--

--

Amitpal Singh Dhillon

vCISO, previously, from Oracle Inc, Sourcefire, Cisco Systems, and Applied Materials.