JVM vs. Native Java Compilation
Summary
There are many ways to optimize Java applications, see:
Optimization of Java Applications β CPU Usage, Memory Usage, Startup Time, Resource Efficiency
Depending on your use case, native compilation can be a potential optimization.
Comparisons
envite (2024)
GitHub - envite-consulting/showcase-graalvm
Red Hat (2022)
Source: https://www.redhat.com/en/resources/greener-java-applications-detail
Setup:
- application: CRUD application that queries a database via a REST interface
- load generator: wrk2
- energy measurement: RAPL
- machine: 2 CPUs, 16 cores per CPU
- JVM Heap was allowed to use up to 12 GB memory
Results:
- density test with a fixed workload (800 transactions/s): native is better because is requires less resources β less embodied carbon
- capacity test with as much load as possible: application throughput is higher with JVM than native β less carbon per request
Red Hat Quarkus Lab Validation (2020)
Sipek et al. (2020)
@Sipek.etal.2020.EnhancingPerformanceCloudbased
Conclusion
Use case for native:
- low workload (throughput isn't the bottleneck)
- resource-constrained or hold hardware (especially memory)
- high re-deploy rate (applications never get warmed up before being spun down
- serverless
Use case for JVM
- high workload (you need lots of throughput)
- long-lived processes (the rapid start of native doesn't save you much over the lifetime)
- stable workload or very little elasticity in underlying orchestration
π References
Writing Greener Java Applications by Holly Cummins
Quarkus in Action (Martin Ε tefanko and Jan MartiΕ‘ka, 2025)