GraalVM für Java-Leistung (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 für Java-Leistung (Windows Developer Build)
Spring Framework-Tools für Java-Entwickler
Erstellen einer Java-Entwicklungsumgebung (für Mac)
Erstellen Sie ffmpeg 4.3.1 unter Ubuntu für Windows
Aktualisieren der Java-Umgebung von Windows mit Chocolatey
Vagabund Java bauen
Für JAVA-Lernen (2018-03-16-01)
2017 IDE für Java
Erstellen Sie eine Entwicklungsumgebung für Docker, Java und Code
Java für Anweisung
VSCode Java Debugger für Java Build fehlgeschlagen Ursachen und Gegenmaßnahmen
[Java] für Anweisung, während Anweisung
[Java] Paket für die Verwaltung
[Java] für Anweisung / erweitert für Anweisung
Leistungsoptimierung für Java-Apps
Java baut ein Dreieck
Erster Gradle Build (Java)
Gegenmaßnahmen für OutOfMemoryError in Java
NLP für Java (NLP4J) (2)
(Memo) Java für Anweisung
NLP für Java (NLP4J) (1)
Erstellen Sie Java mit Wercker
Java Performance Kapitel 3 Java Performance Toolbox
Bereitstellen einer Java-Umgebung mit Windows Subsystem für Linux (WSL)