Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can a GraalVM app be deployed on a "regular" VM

Tags:

java

graalvm

In order to gain the performance benefits offered by GraalVM, the application must be compiled using GraalVM's compiler. However, what's not clear to me is whether the application must also be executed by GraalVM, or whether it can be deployed to a "regular" VM (e.g. OpenJDK) in order to benefit from the improved performance?

Some additional details which may be relevant

  • I'm using JDK 11
  • The application in question only uses JDK languages, e.g. Java, Kotlin, Groovy
  • The build artifact is a JAR file, i.e. GraalVM native images are not used
like image 464
Antonio Dragos Avatar asked Sep 14 '25 08:09

Antonio Dragos


2 Answers

If you have compiled your code with JVM Runtime mode, than you can run your application on any JVM. There is no compulsion of running the application with GraalVM.

If you have compile your code with Native Image compiler, than it will create a native executable binary which can be directly executed without usage of any JVM.

like image 77
Digsb Avatar answered Sep 17 '25 00:09

Digsb


GraalVM is based on OpenJDK with some extras; one of them is a state-of-the-art compiler.

The Graal compiler is very versatile; it is used to compile native images (AOT mode) but can also be used as a JIT compiler, replacing C2, which is the default shipped in OpenJDK.

The term compiler is a bit overloaded in this case. The traditional Java "compilers" e.g. javac/ecj, compile Java sources to bytecode. The "optimizing compilers" e.g. Graal and C2, compile bytecode to highly optimized assembly.

GraalVM uses a different "optimizing compiler" (Graal), which may indeed give some speedup compared to a vanilla OpenJDK (C2) but that's very dependent on your workload, you should always measure yourself.

Additional reference: Twitter's Quest for a Wholly Graal Runtime by Chris Thalinger

like image 25
mukel Avatar answered Sep 16 '25 23:09

mukel