GraalVM for Java Performance (Windows Developer Build)

What is GraalVM? High-performance polyglot VM

Install GraalVM Download GraalVM from OTN Windows GraalVM Early Adopter Support for GraalVM on Windows is currently under development. Note: You will need to accept the license at the top of the page before downloading: Download GraalVM based on JDK8, preview for Windows (19.0.1) (cksum - 3226557420) Extract the downloaded file to any directory

Expand-Archive "C:\<DOWNLOADED FOLDER>\graalvm-ee-windows-amd64-19.0.1.zip" "C:\Program Files\Java\"

Installation Check

PS C:> & 'C:\Program Files\Java\graalvm-ee-19.0.1\bin\java.exe' -version
java.exe : java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b31)
Java HotSpot(TM) GraalVM EE 19.0.1 (build 25.212-b31-jvmci-19-b01, mixed mode)

Case.2 Performance Check and Compare

  1. Compile JDK1.8 + Run JDK1.8
  2. Compile JDK1.8 + Run JDK11
  3. Compile JDK1.8 + Run GraalVM Java (NOT native)

GraalSample.java


public class GraalSample {
    static final int ITERATIONS = Math.max(Integer.getInteger("iterations", 1), 1);
    public static void main(String[] args) {
        String sentence = String.join(" ", args);
        for (int iter = 0; iter < ITERATIONS; iter++) {
            if (ITERATIONS != 1) System.out.println("-- iteration " + (iter + 1) + " --");
            long total = 0, start = System.currentTimeMillis(), last = start;
            for (int i = 1; i < 10000000; i++) {
                total += sentence.chars().filter(Character::isUpperCase).count();
                if (i % 1000000 == 0) {
                    long now = System.currentTimeMillis();
                    System.out.printf("%d (%d ms)%n", i / 1000000, now - last);
                    last = now;
                }
            }
            System.out.printf("total: %d (%d ms)%n", total, System.currentTimeMillis() - start);
        }
    }
}

Compile GraalSample.java by JDK1.8

PS C:> & 'C:\Program Files\Java\jdk1.8.0\bin\javac.exe' -source 1.8 -d C:\Temp GraalSample.java

Run JDK1.8

PS C:\Temp> Measure-Command { & 'C:\Program Files\Java\jdk1.8.0\bin\java.exe' GraalSample }
TotalMilliseconds : 1272.6506
TotalMilliseconds : 1157.0957
TotalMilliseconds : 1155.1402
TotalMilliseconds : 1165.2418
TotalMilliseconds : 1176.3292

PS C:\Temp> Measure-Command { & 'C:\Program Files\Java\jdk1.8.0\bin\java.exe' GraalSample In 2019 I would like to run ALL languages in one VM.}
TotalMilliseconds : 3806.2965
TotalMilliseconds : 3795.3136
TotalMilliseconds : 3800.0122
TotalMilliseconds : 3791.7407
TotalMilliseconds : 3783.8776

Run GraalVM Java (NOT native)

PS C:\Temp>  Measure-Command { & 'C:\Program Files\Java\graalvm-ee-19.0.1\bin\java.exe' GraalSample }
TotalMilliseconds : 2400.0316
TotalMilliseconds : 2394.7220
TotalMilliseconds : 2413.2863
TotalMilliseconds : 2372.2009
TotalMilliseconds : 2870.4932

PS C:\Temp>  Measure-Command { & 'C:\Program Files\Java\graalvm-ee-19.0.1\bin\java.exe' GraalSample In 2019 I would like to run ALL languages in one VM. }
TotalMilliseconds : 3579.2619
TotalMilliseconds : 3628.8374
TotalMilliseconds : 3516.2905
TotalMilliseconds : 3453.3161
TotalMilliseconds : 3655.8266

Conclusion

GraalVM takes overhead for the first few times, BUT GraalVM is more stable and FASTER than JDK1.8, as the number of iterations increase. It seems GraalVM isn't suitable for single-shot like a simple cli java programs.

Recommended Posts

GraalVM for Java Performance (Windows Developer Build)
Spring Framework tools for Java developer
Build Java development environment (for Mac)
Build ffmpeg 4.3.1 on Ubuntu for Windows
Modern Java environment for Windows using Chocolatey
vagrant java build
For JAVA learning (2018-03-16-01)
2017 IDE for Java
Build a development environment for Docker, java, vscode
Java for statement
VSCode Java Debugger for Java Build failed Causes and countermeasures
[Note] I suddenly can't build with Docker for windows.
[Java] for statement, while statement
[Java] Package for management
[Java] for statement / extended for statement
Java app performance tuning
java build a triangle
First gradle build (Java)
Countermeasures for Java OutOfMemoryError
NLP for Java (NLP4J) (2)
(Memo) Java for statement
NLP for Java (NLP4J) (1)
Build Java with Wercker
Java Performance Chapter 3 Java Performance Toolbox
Deploying a Java environment with Windows Subsystem for Linux (WSL)