Skip to content

Commit 4f09c59

Browse files
committed
Add info how to enable Graal JIT with Oracle JDK
1 parent 2b2a1a7 commit 4f09c59

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

compiler/java-stream-benchmark/README.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Java Stream Benchmark
22

3-
This repository contains the code for a simple Java Stream benchmark designed to run on a JDK.
4-
3+
This repository contains the code for a simple Java Stream benchmark designed to run on the [GraalVM JDK](http://graalvm.org) and the [Oracle JDK](https://www.oracle.com/java/technologies/downloads/).
54
## Preparation
65

76
1. Download and install the GraalVM JDK using [SDKMAN!](https://sdkman.io/). For other installation options, visit the [Downloads page](https://www.graalvm.org/downloads/).
@@ -29,23 +28,36 @@ Now you can run this benchmark with whatever `java` you have on your machine and
2928
Note that the results you see can be influenced by the hardware you are running this benchmark on, the CPU load, and other factors.
3029
Interpret them responsibly.
3130

32-
## Run the Benchmark
31+
### GraalVM JDK with Graal JIT
32+
33+
Run the benchmark with the default GraalVM JIT compiler by executing the _target/benchmarks.jar_ file:
34+
```bash
35+
java -jar target/benchmarks.jar
36+
```
37+
38+
### GraalVM JDK with Graal JIT Deactivated
3339

34-
1. Run the benchmark on the **GraalVM JDK with the default JIT compiler (Graal)** by executing the _target/benchmarks.jar_ file:
40+
Now deactivate the Graal compiler and run the benchmark on the same JVM (GraalVM):
41+
```bash
42+
java -XX:-UseJVMCICompiler -jar target/benchmarks.jar
43+
```
44+
This way, the Graal JIT compiler is not be used as the JVMCI compiler and the JVM uses its default one (C2).
45+
46+
### Oracle JDK with Graal JIT
47+
48+
Note that starting with Oracle JDK 23, the **Oracle GraalVM JIT compiler (Graal JIT) is now included among the JITs available as part of the Oracle JDK**.
49+
Read more in [this blog post](https://blogs.oracle.com/java/post/including-the-graal-jit-in-oracle-jdk-23).
50+
51+
1. Switch the JVM from GraalVM (Oracle GraalVM or Community Edition) to Oracle JDK 23 or higher. You can quickly do that with using [SDKMAN!](https://sdkman.io/):
3552
```bash
36-
java -jar target/benchmarks.jar
53+
sdk install java 23.0.1-oracle
3754
```
3855

39-
2. Now **deactivate the Graal compiler** using the `-XX:-UseJVMCICompiler` option and run the benchmark on the same JVM (GraalVM):
56+
2. Run this benchmark with the Graal JIT compiler enabled. For that, pass the `-XX:+UseGraalJIT` option to `java`:
4057
```bash
41-
java -XX:-UseJVMCICompiler -jar target/benchmarks.jar
58+
java -XX:+UnlockExperimentalVMOptions -XX:+UseGraalJIT -jar target/benchmarks.jar
4259
```
43-
This way, the Graal JIT compiler is not be used as the JVMCI compiler and the JVM uses its default one.
44-
45-
## Learn More
4660

47-
Learn more about the Graal JIT compiler from [its official documentation](https://www.graalvm.org/reference-manual/java/compiler/).
61+
> To switch between JVMs in the same terminal window (without affecting the global setting), use the `sdk` tool. For example, to switch back to Oracle GraalVM for JDK 23, run: `sdk use java 23.0.1-graal`.
4862

49-
Note that starting with Oracle JDK 23, the **Oracle GraalVM JIT compiler (Graal JIT) is now included among the JITs available as part of the Oracle JDK**.
50-
To run a Java application on Oracle JDK with the Graal JIT compiler, pass the `-XX:+UseGraalJIT` option to `java`.
51-
Read more in [this blog post](https://blogs.oracle.com/java/post/including-the-graal-jit-in-oracle-jdk-23).
63+
Learn more about the Graal JIT compiler from [its official documentation](https://www.graalvm.org/reference-manual/java/compiler/).

0 commit comments

Comments
 (0)