Skip to content

Commit f5ba182

Browse files
committed
Test docs/examples with GraalVM EE Java 11 21.3-dev
1 parent d1d1aba commit f5ba182

6 files changed

+191
-186
lines changed

docs/enterprise-overview/architecture-overview.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ Java on Trufle is an experimental technology in GraalVM, available as of version
5656

5757
## Available Distributions
5858

59-
GraalVM Enterprise distributions are based on Oracle JDK 8, 11, and 16.
59+
GraalVM Enterprise distributions are based on Oracle JDK 8, 11, and 17.
6060
GraalVM Enterprise releases include all Oracle Java critical patch updates (CPUs), which are released on a regular schedule to remedy defects and known vulnerabilities.
6161

6262
GraalVM Enterprise is available for Linux, macOS, and Windows platforms on x86 64-bit systems, and for Linux on ARM 64-bit system.
63-
The GraalVM Enterprise distribution based on Oracle JDK 16 is experimental with [several known limitations](https://docs.oracle.com/en/graalvm/enterprise/21/docs/overview/known-issues/).
6463
Depending on the platform, the distributions are shipped as *.tar.gz* or *.zip* archives.
6564

6665
## Certified Platforms
@@ -104,7 +103,7 @@ Tools/Utilities:
104103

105104
Runtimes:
106105

107-
* [Node.js](/reference-manual/js/) -- the Node.js 14.16.1 runtime for JavaScript
106+
* [Node.js](/reference-manual/js/) -- the Node.js 14.17.6 runtime for JavaScript
108107
* [Python](/reference-manual/python/) -- Python 3.8.5 compatible
109108
* [Ruby](/reference-manual/ruby/) -- Ruby 2.7.3 compatible
110109
* [R](/reference-manual/r/) -- GNU R 4.0.3 compatible

docs/examples/java-kotlin-aot.md

+35-31
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,43 @@ permalink: /examples/java-kotlin-aot/
77

88
# Build a Native Image of a Java and Kotlin Application
99

10-
This example demonstrates how to compile a Java and Kotlin application
11-
ahead-of-time into a native executable, and illustrates the advantages.
10+
This example demonstrates how to compile a Java and Kotlin application ahead-of-time into a native executable, and illustrates the advantages.
1211

13-
### Preparation
14-
15-
This example requires the [Maven](https://maven.apache.org/) build tool.
12+
## Preparation
1613

1714
1. Download or clone the repository and navigate into the `java-kotlin-aot` directory:
1815
```shell
1916
git clone https://github.com/graalvm/graalvm-demos
2017
cd graalvm-demos/java-kotlin-aot
2118
```
22-
This is a simple Java and Kotlin application showing how easy it is to
23-
interoperate between JVM-based languages. A Java method accesses a String from
24-
Kotlin and calls a Kotlin function, which later accesses a String from a Java
25-
class. Before running this example, you need to build the application.
26-
27-
Note: You can use any JDK for building the application. However, `javac` from GraalVM
28-
in the build script is used to simplify the prerequisites so another JDK does not need to be installed.
29-
30-
2. Having installed GraalVM, export the home directory as `$GRAALVM_HOME` and add `$GRAALVM_HOME/bin`
31-
to the path, using a command-line shell for Linux:
32-
```shell
33-
export GRAALVM_HOME=/home/${current_user}/path/to/graalvm
19+
This is a simple Java and Kotlin application showing how easy it is to interoperate between JVM-based languages.
20+
A Java method accesses a String from Kotlin and calls a Kotlin function, which later accesses a String from a Java class.
21+
Before running this example, you need to build the application.
22+
23+
Note: You can use any JDK for building the application. However, `javac` from GraalVM in the build script is used to simplify the prerequisites so another JDK does not need to be installed.
24+
25+
2. [Download GraalVM](https://www.graalvm.org/downloads/), unzip the archive, export the GraalVM home directory as the `$JAVA_HOME` and add `$JAVA_HOME/bin` to the `PATH` environment variable:
26+
On Linux:
27+
```bash
28+
export JAVA_HOME=/home/${current_user}/path/to/graalvm
29+
export PATH=$JAVA_HOME/bin:$PATH
30+
```
31+
On macOS:
32+
```bash
33+
export JAVA_HOME=/Users/${current_user}/path/to/graalvm/Contents/Home
34+
export PATH=$JAVA_HOME/bin:$PATH
35+
```
36+
On Windows:
37+
```bash
38+
setx /M JAVA_HOME "C:\Progra~1\Java\<graalvm>"
39+
setx /M PATH "C:\Progra~1\Java\<graalvm>\bin;%PATH%"
40+
```
41+
Note that your paths are likely to be different depending on the download location.
42+
43+
3&#46; [Install Native Image](../reference-manual/native-image/README.md/#install-native-image) by running.
44+
```bash
45+
gu install native-image
3446
```
35-
For macOS, use:
36-
```shell
37-
export GRAALVM_HOME=/Users/${current_user}/path/to/graalvm/Contents/Home
38-
```
39-
Note that your paths are likely to be different depending on the download location.
40-
41-
3&#46; [Install Native Image](../reference-manual/native-image/README.md/#install-native-image) to make use of the `native-image` utility.
4247

4348
4&#46; Then execute:
4449
```shell
@@ -48,18 +53,17 @@ Note that your paths are likely to be different depending on the download locati
4853
Have a look at the `build.sh` script which creates a native executable from a Java class.
4954
The `native-image` utility compiles the application ahead-of-time for faster startup and lower general overhead at runtime.
5055
```shell
51-
$GRAALVM_HOME/bin/native-image -cp ./target/mixed-code-hello-world-1.0-SNAPSHOT.jar -H:Name=helloworld -H:Class=hello.JavaHello -H:+ReportUnsupportedElementsAtRuntime --allow-incomplete-classpath
56+
$JAVA_HOME/bin/native-image --no-fallback -cp ./target/mixed-code-hello-world-1.0-SNAPSHOT-jar-with-dependencies.jar -H:Name=helloworld -H:Class=hello.JavaHello -H:+ReportUnsupportedElementsAtRuntime
5257
```
5358

54-
It takes a few parameters: the classpath, the main class of the application with
55-
`-H:Class=...`, and the name of the resulting executable with `-H:Name=...`.
59+
It takes a few parameters: the classpath, the main class of the application with `-H:Class=...`, and the name of the resulting executable with `-H:Name=...`.
5660

57-
After executing the `native-image` command, check the directory. It should have
58-
produced the executable file, `helloworld`.
61+
After executing the `native-image` command, check the directory.
62+
It should have produced the executable file, `helloworld`.
5963

60-
### Running the Application
64+
## Running the Application
6165

62-
To run the application, you need to execute the JAR file in the `target` dir.
66+
To run the application, you need to execute the JAR file in the `target` directory.
6367
You can run it as a normal Java application using `java`.
6468
Or, since we have a native executable prepared, you can run that directly.
6569
The `run.sh` file executes both, and times them with the `time` utility:

docs/examples/java-performance-examples.md

+37-47
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ permalink: /examples/java-performance-examples/
77

88
# Java Performance Examples
99

10-
The GraalVM compiler achieves excellent performance, especially for highly
11-
abstracted programs, due to its versatile optimization techniques. Code using
12-
more abstraction and modern Java features like Streams or Lambdas will see
13-
greater speedups. The examples below demonstrate this.
10+
The GraalVM compiler achieves excellent performance, especially for highly abstracted programs, due to its versatile optimization techniques.
11+
Code using more abstraction and modern Java features like Streams or Lambdas will see greater speedups.
12+
The examples below demonstrate this.
1413

15-
### Running Examples
14+
## Running Examples
1615

17-
#### Streams API Example
16+
### Streams API Example
1817

19-
A simple example based on the [Streams API](https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html)
20-
is used here to demonstrate performance gains when using the GraalVM compiler.
21-
This example counts the number of uppercase characters in a body of text. To
22-
simulate a large load, the same sentence is processed 10 million times:
18+
A simple example based on the [Streams API](https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html) is used here to demonstrate performance gains when using the GraalVM compiler.
19+
This example counts the number of uppercase characters in a body of text.
20+
To simulate a large load, the same sentence is processed 10 million times:
2321

2422
1&#46; Save the following code snippet to a file named `CountUppercase.java`:
2523

@@ -49,62 +47,54 @@ public class CountUppercase {
4947
```shell
5048
javac CountUppercase.java
5149
java CountUppercase In 2021 I would like to run ALL languages in one VM.
52-
1 (297 ms)
53-
2 (452 ms)
54-
3 (136 ms)
55-
4 (88 ms)
56-
5 (107 ms)
57-
6 (135 ms)
58-
7 (88 ms)
59-
8 (87 ms)
60-
9 (78 ms)
61-
total: 69999993 (1550 ms)
50+
1 (319 ms)
51+
2 (275 ms)
52+
3 (164 ms)
53+
4 (113 ms)
54+
5 (100 ms)
55+
6 (124 ms)
56+
7 (86 ms)
57+
8 (76 ms)
58+
9 (77 ms)
59+
total: 69999993 (1414 ms)
6260
```
6361

64-
The warmup time depends on numerous factors like the source code or how
65-
many cores a machine has. If the performance profile of `CountUppercase` on your
66-
machine does not match the above, run it for more iterations by adding
67-
`-Diterations=N` just after `java` for some `N` greater than 1.
62+
The warmup time depends on numerous factors like the source code or how many cores a machine has.
63+
If the performance profile of `CountUppercase` on your machine does not match the above, run it for more iterations by adding `-Diterations=N` just after `java` for some `N` greater than 1.
6864

6965
3&#46; Add the `-Dgraal.PrintCompilation=true` option to see statistics for the compilations:
7066
```shell
7167
java -Dgraal.PrintCompilation=true CountUppercase In 2021 I would like to run ALL languages in one VM.
7268
```
7369

74-
This option prints a line after each compilation that shows the method
75-
compiled, time taken, bytecodes processed (including inlined methods), size
76-
of machine code produced, and amount of memory allocated during compilation.
70+
This option prints a line after each compilation that shows the method compiled, time taken, bytecodes processed (including inlined methods), size of machine code produced, and amount of memory allocated during compilation.
7771

78-
4&#46; Use the `-XX:-UseJVMCICompiler` option to disable the GraalVM compiler and
79-
use the native top tier compiler in the VM to compare performance:
72+
4&#46; Use the `-XX:-UseJVMCICompiler` option to disable the GraalVM compiler and use the native top tier compiler in the VM to compare performance:
8073
```shell
8174
java -XX:-UseJVMCICompiler CountUppercase In 2021 I would like to run ALL languages in one VM.
82-
1 (747 ms)
83-
2 (806 ms)
84-
3 (640 ms)
85-
4 (771 ms)
86-
5 (606 ms)
87-
6 (582 ms)
88-
7 (623 ms)
89-
8 (564 ms)
90-
9 (682 ms)
91-
total: 69999993 (6713 ms)
75+
1 (492 ms)
76+
2 (441 ms)
77+
3 (443 ms)
78+
4 (470 ms)
79+
5 (422 ms)
80+
6 (382 ms)
81+
7 (407 ms)
82+
8 (425 ms)
83+
9 (343 ms)
84+
total: 69999993 (4249 ms)
9285
```
9386

94-
The preceding example demonstrates the benefits of partial escape analysis (PEA)
95-
and advanced inlining, which combine to significantly reduce heap allocation.
87+
The preceding example demonstrates the benefits of partial escape analysis (PEA) and advanced inlining, which combine to significantly reduce heap allocation.
9688
The results were obtained using Oracle GraalVM Enterprise Edition.
9789

98-
The GraalVM Community Edition still has good performance compared to the native top-tier
99-
compiler as shown below. You can simulate the Community Edition on the Enterprise Edition
100-
by adding the option `-Dgraal.CompilerConfiguration=community`.
90+
The GraalVM Community Edition still has good performance compared to the native top-tier compiler as shown below.
91+
You can simulate the Community Edition on the Enterprise Edition by adding the option `-Dgraal.CompilerConfiguration=community`.
10192

102-
#### Sunflow Example
93+
### Sunflow Example
10394

10495
[Sunflow](http://sunflow.sourceforge.net) is an open source rendering engine.
10596
The following example is a simplified version of the Sunflow engine core code.
106-
It performs calculations to blend various values for a point of light in a
107-
rendered scene.
97+
It performs calculations to blend various values for a point of light in a rendered scene.
10898

10999
1&#46; Save the following code snippet to a file named `Blender.java`:
110100
```java

docs/examples/java-simple-stream-benchmark.md

+29-30
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,49 @@ permalink: /examples/java-simple-stream-benchmark/
77

88
# Simple Java Stream Benchmark
99

10-
This application is a small benchmark of the Java Stream API. It demonstrates how
11-
the GraalVM compiler can achieve better performance for highly
12-
abstracted programs like those using Streams, Lambdas, or other Java features.
13-
14-
### Preparation
15-
16-
This example requires the [Maven](https://maven.apache.org/) build tool.
17-
18-
1&#46; Download or clone the repository and navigate into the `java-simple-stream-benchmark` directory:
10+
This application is a small benchmark of the Java Stream API. It demonstrates how the GraalVM compiler can achieve better performance for highly abstracted programs like those using Streams, Lambdas, or other Java features.
11+
12+
## Preparation
13+
14+
1&#46; [Download GraalVM](https://www.graalvm.org/downloads/), unzip the archive, export the GraalVM home directory as the `$JAVA_HOME` and add `$JAVA_HOME/bin` to the `PATH` environment variable:
15+
On Linux:
16+
```bash
17+
export JAVA_HOME=/home/${current_user}/path/to/graalvm
18+
export PATH=$JAVA_HOME/bin:$PATH
19+
```
20+
On macOS:
21+
```bash
22+
export JAVA_HOME=/Users/${current_user}/path/to/graalvm/Contents/Home
23+
export PATH=$JAVA_HOME/bin:$PATH
24+
```
25+
On Windows:
26+
```bash
27+
setx /M JAVA_HOME "C:\Progra~1\Java\<graalvm>"
28+
setx /M PATH "C:\Progra~1\Java\<graalvm>\bin;%PATH%"
29+
```
30+
Note that your paths are likely to be different depending on the download location.
31+
32+
2&#46; Download or clone the repository and navigate into the `java-simple-stream-benchmark` directory:
1933
```shell
2034
git clone https://github.com/graalvm/graalvm-demos
2135
cd graalvm-demos/java-simple-stream-benchmark
2236
```
2337

24-
2&#46; Build the benchmark. You can manually execute `mvn package`, but there is also
25-
a `build.sh` script included for your convenience:
38+
3&#46; Build the benchmark. You can manually execute `mvn package`, but there is also a `build.sh` script included for your convenience:
2639
```shell
2740
./build.sh
2841
```
29-
30-
3&#46; Export the GraalVM home directory as the `$GRAALVM_HOME` and add `$GRAALVM_HOME/bin`
31-
to the path, using a command-line shell for Linux:
32-
```shell
33-
export GRAALVM_HOME=/path/to/graalvm
34-
```
35-
For macOS:
36-
```shell
37-
export GRAALVM_HOME=/path/to/graalvm/Contents/Home
38-
```
39-
4042
Now you are all set to execute the benchmark and compare the results between different JVMs.
4143

42-
### Running the Benchmark
44+
## Running the Benchmark
4345

4446
To run the benchmark, you need to execute the `target/benchmarks.jar` file.
4547
You can run it with the following command:
4648
```shell
4749
java -jar target/benchmarks.jar
4850
```
49-
If you would like to run the benchmark on a different JVM, you can run it with
50-
whatever `java` you have. However, if you just want to run it on the same JVM,
51-
but without the GraalVM compiler, you may add the `-XX:-UseJVMCICompiler` option
52-
into the same command:
51+
If you would like to run the benchmark on a different JVM, you can run it with whatever `java` you have.
52+
However, if you just want to run it on the same JVM, but without the GraalVM compiler, you may add the `-XX:-UseJVMCICompiler` option into the same command:
5353
```shell
5454
java -XX:-UseJVMCICompiler -jar target/benchmarks.jar
5555
```
@@ -58,7 +58,6 @@ This way, the GraalVM compiler will not be used as the JVMCI compiler and the JV
5858

5959
### Note about Results
6060

61-
The benchmark mode is `AverageTime` in nanoseconds per operation, which means
62-
lower numbers are better. Note that the results you see can be influenced by the
63-
hardware you are running this benchmark on, the CPU load, and other factors.
61+
The benchmark mode is `AverageTime` in nanoseconds per operation, which means lower numbers are better.
62+
Note that the results you see can be influenced by the hardware you are running this benchmark on, the CPU load, and other factors.
6463
Interpret them responsibly.

0 commit comments

Comments
 (0)