You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference-manual/java/Operations.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,8 +14,9 @@ The first thing to confirm when measuring performance is that the Java Virtual M
14
14
15
15
GraalVM is configured to use the Graal JIT compiler as the top tier compiler by default.
16
16
17
-
To enable the Graal JIT compiler for use in the [Java HotSpot Virtual Machine](https://docs.oracle.com/en/java/javase/22/vm/java-virtual-machine-technology-overview.html), use the `-XX:+UseGraalJIT` option.
17
+
To enable the Graal JIT compiler for use in the [Java HotSpot Virtual Machine](https://docs.oracle.com/en/java/javase/23/vm/java-virtual-machine-technology-overview.html){:target="_blank"}, use the [`-XX:+UseGraalJIT`](https://download.java.net/java/early_access/jdk23/docs/specs/man/java.html#enabling-the-graal-jit-compiler){:target="_blank"} option.
18
18
(The `-XX:+UseGraalJIT` option has to be used together with the `-XX:+UnlockExperimentalVMOptions` option that unlocks this experimental integration.)
19
+
19
20
The following example runs the Java application `com.example.myapp` with the Graal JIT compiler enabled:
20
21
21
22
```shell
@@ -33,18 +34,18 @@ Using "Graal Enterprise compiler with Truffle extensions" loaded from a PGO opti
33
34
34
35
Optimizing a JVM-based application is a science in itself.
35
36
Compilation may not even be a factor in the case of poor performance as the problem may lie in any other part of the JVM (I/O, garbage collection, threading, and so on), or in a poorly written application, or third-party library code.
36
-
For this reason, it is worth employing the [JDK Mission Control](https://www.oracle.com/java/technologies/jdk-mission-control.html) tool chain to diagnose your application's behavior.
37
+
For this reason, it is worth employing the [JDK Mission Control](https://www.oracle.com/java/technologies/jdk-mission-control.html){:target="_blank"} toolchain to diagnose your application's behavior.
37
38
38
39
You can also compare performance against the native top-tier compiler in the JVM by adding `-XX:-UseJVMCICompiler` to the command line.
39
40
40
41
If you observe a significant performance regression when using the Graal JIT compiler, please open an issue on GitHub.
41
42
Attach a Java Flight Recorder log and instructions to reproduce the issue—this makes investigation easier and thus increases the chances of a fix.
42
-
Even better is if you can submit a [JMH](http://openjdk.java.net/projects/code-tools/jmh/) benchmark that represents the hottest parts of your application (as identified by a profiler).
43
+
Even better is if you can submit a [JMH](http://openjdk.java.net/projects/code-tools/jmh/){:target="_blank"} benchmark that represents the hottest parts of your application (as identified by a profiler).
43
44
This allows us to quickly pinpoint absent optimization opportunities or to provide suggestions on how to restructure your code to avoid or reduce performance bottlenecks.
44
45
45
46
## Troubleshooting the Graal JIT Compiler
46
47
47
-
If you spot a security vulnerability, please do **not** report it via GitHub Issues or the public mailing lists, but via the process outlined in the [Reporting Vulnerabilities guide](https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html).
48
+
If you spot a security vulnerability, please do **not** report it via GitHub Issues or the public mailing lists, but via the process outlined in the [Reporting Vulnerabilities guide](https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html){:target="_blank"}.
48
49
49
50
### Compilation Exceptions
50
51
@@ -57,7 +58,7 @@ In this case, just before the JVM exits, all diagnostic output captured during r
57
58
Graal diagnostic output saved in /Users/demo/graal-dumps/1499768882600/graal_diagnostics_64565.zip
58
59
```
59
60
60
-
You can then attach the ZIP file to an issue on [GitHub](https://github.com/oracle/graal/issues).
61
+
You can then attach the ZIP file to an issue on [GitHub](https://github.com/oracle/graal/issues){:target="_blank"}.
61
62
62
63
As well as `Silent` and `Diagnose`, the following values for `graal.CompilationFailureAction` are available:
63
64
*`Print`: prints a message and stack trace to the console but does not perform recompilation.
In this example, there is probably an error in the code produced by the Graal JIT compiler for `NodeLIRBuilder.matchComplexExpressions`.
94
95
95
-
When filing an issue on [GitHub](https://github.com/oracle/graal/issues) for such a crash, you should first attempt to reproduce the crash with extra diagnostics enabled for the compilation of the problematic method.
96
+
When filing an issue on [GitHub](https://github.com/oracle/graal/issues){:target="_blank"} for such a crash, you should first attempt to reproduce the crash with extra diagnostics enabled for the compilation of the problematic method.
96
97
In this example, you would add the following options to your command line:
These options are described in more detail [here](https://github.com/oracle/graal/blob/master/compiler/docs/Debugging.md).
102
+
These options are described in more detail in the [compiler debugging documentation](https://github.com/oracle/graal/blob/master/compiler/docs/Debugging.md){:target="_blank"}.
102
103
In brief, these options tell the Graal JIT compiler to capture snapshots of its state at verbosity level 2 while compiling any method named `matchComplexExpressions` in a class with a simple name of `NodeLIRBuilder`.
103
-
The complete format of the `MethodFilter` option is described in [MethodFilterHelp.txt](https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/doc-files/MethodFilterHelp.txt).
104
+
The complete format of the `MethodFilter` option is described in [MethodFilterHelp.txt](https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/doc-files/MethodFilterHelp.txt){:target="_blank"}.
104
105
105
106
Quite often, the crash location does not exist directly in the problematic method mentioned in the crash log but comes from an inlined method.
106
107
@@ -148,7 +149,7 @@ ls -l /Users/demo/graal-dumps/1499768882600
Copy file name to clipboardExpand all lines: docs/reference-manual/java/Options.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ To see the available configurations, supply the value `help` to this option.
54
54
### Performance Tuning Options
55
55
56
56
*`-Djdk.graal.Vectorization={ true | false }`: To disable the auto vectorization optimization (only available in Oracle GraalVM). (Default: `true`.)
57
-
*`-Djdk.graal.OptDuplication={ true | false }`: To disable the [path duplication optimization](http://ssw.jku.at/General/Staff/Leopoldseder/DBDS_CGO18_Preprint.pdf) (only available in Oracle GraalVM). (Default: `true`.)
57
+
*`-Djdk.graal.OptDuplication={ true | false }`: To disable the [path duplication optimization](http://ssw.jku.at/General/Staff/Leopoldseder/DBDS_CGO18_Preprint.pdf){:target="_blank"} (only available in Oracle GraalVM). (Default: `true`.)
58
58
*`-Djdk.graal.TuneInlinerExploration=<value>`: To tune for better peak performance or faster warmup.
59
59
It automatically adjusts values governing the effort spent during inlining. The value of the option is a float clamped between `-1` and `1` inclusive. Anything below `0` reduces inlining effort and anything above `0` increases inlining effort. In general, peak performance is improved with more inlining effort while less inlining effort improves warmup (albeit to a lower peak). Note that this option is only a heuristic and the optimal value can differ from application to application (only available in Oracle GraalVM).
GraalVM is based on the [Java HotSpot Virtual Machine](https://docs.oracle.com/en/java/javase/22/vm/java-virtual-machine-technology-overview.html), so any application that runs on the Java HotSpot Virtual Machine will also on GraalVM.
10
+
GraalVM is based on the [Java HotSpot Virtual Machine](https://docs.oracle.com/en/java/javase/23/vm/java-virtual-machine-technology-overview.html), so any application that runs on the Java HotSpot Virtual Machine will also on GraalVM.
11
11
12
12
GraalVM includes an advanced compiler written in Java, known as the _Graal compiler_.
13
13
At runtime, just like any other Java Virtual Machine (JVM), GraalVM loads an application and analyzes its code to detect performance bottlenecks, or _hot spots_.
14
14
GraalVM passes the performance-critical code to the Graal just-in-time (JIT) compiler, which compiles it to machine code and then returns it.
15
15
16
16
The Graal compiler can improve the efficiency and the speed of applications written in Java, Scala, Kotlin, or other JVM languages through its unique approaches to code analysis and optimization.
17
17
For example, it assures performance advantages for highly-abstracted applications due to its ability to remove costly object allocations.
18
-
For more information, see the [platform-independent compiler optimizations in GraalVM Community Edition](https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/phases/CEOptimization.java){:target="_blank"}.
18
+
See the [`CEOptimization enum`](https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/phases/CEOptimization.java){:target="_blank"} in the GraalVM Community Edition GitHub repository for more information about platform-independent compiler optimizations.
19
19
20
-
> The Graal (JIT) compiler is now also integrated with the [Java HotSpot Virtual Machine](https://docs.oracle.com/en/java/javase/22/vm/java-virtual-machine-technology-overview.html).
21
-
To find out more, see [Graal Compiler](compiler.md).
20
+
> The Graal (JIT) compiler is now also integrated with the Java HotSpot Virtual Machine.
21
+
To find out more, see the section [Graal Compiler](compiler.md).
22
22
23
23
## Interoperability
24
24
25
25
GraalVM also includes the [Truffle language implementation framework](../../../truffle/docs/README.md)—a library, written in Java—to build interpreters for programming languages, which then run on GraalVM.
26
26
These "Graal languages" can consequently benefit from the optimization possibilities of the Graal compiler.
27
27
The pipeline for such compilation is:
28
28
29
-
* The Truffle framework code and data (Abstract Syntax Trees) is partially evaluated to produce a compilation graph. When such an Abstract Syntax Tree (AST) is "hot" (that is, called many times), it is scheduled for compilation by the compiler.
30
-
* The compilation graph is optimized by the Graal compiler to produce machine code.
31
-
* JVMCI installs this machine code in the JVM's code cache.
32
-
* The AST will automatically redirect execution to the installed machine code once it is available.
29
+
1. The Truffle framework code and data represented by Abstract Syntax Trees (ASTs) are partially evaluated to produce a compilation graph. When such an AST is "hot" (that is, called many times), it is scheduled for compilation by the compiler.
30
+
2. The compilation graph is optimized by the Graal compiler to produce machine code.
31
+
3. JVMCI installs this machine code in the JVM's code cache.
32
+
4. The AST will automatically redirect execution to the installed machine code once it is available.
33
33
34
34
See the [Polyglot Programming](../polyglot-programming.md) and [Embedding Languages](../embedding/embed-languages.md) guides for more information about interoperability with other programming languages.
35
35
36
36
## Ahead-of-time Compilation
37
37
38
-
Besides the Truffle framework, GraalVM incorporates its compiler into an advanced ahead-of-time (AOT) compilation technology—[Native Image](../native-image/README.md)—which translates Java and JVM-based code into a native platform executable.
38
+
Besides the Truffle framework, GraalVM incorporates its compiler into an advanced ahead-of-time (AOT) compilation technology—Native Image—which translates Java and JVM-based code into a native platform executable.
39
39
These native executables start nearly instantaneously, are smaller, and consume less resources than their JVM counterparts, making them ideal for cloud deployments and microservices.
40
40
For more information about AOT compilation, see [Native Image](../native-image/README.md).
41
41
@@ -45,3 +45,4 @@ For more information about AOT compilation, see [Native Image](../native-image/R
The Graal compiler is a dynamic compiler, written in Java, that transforms bytecode into machine code.
12
-
The Graal just-in-time (JIT) compiler is integrated with the [Java HotSpot Virtual Machine](https://docs.oracle.com/en/java/javase/22/vm/java-virtual-machine-technology-overview.html) and [GraalVM](README.md).
13
-
(The open source code of the Graal JIT compiler is available on [GitHub](https://github.com/oracle/graal/tree/master/compiler).)
14
-
12
+
The Graal just-in-time (JIT) compiler is integrated with the Java HotSpot Virtual Machine and GraalVM.
13
+
See [Java Virtual Machine Guide](https://docs.oracle.com/en/java/javase/23/vm/java-virtual-machine-technology-overview.html){:target="_blank"} and the section [GraalVM as a Virtual Machine](README.md) for more information.
14
+
(The open source code of the Graal JIT compiler is available on [GitHub](https://github.com/oracle/graal/tree/master/compiler){:target="_blank"}.)
15
15
16
16
## Compiler Advantages
17
17
18
18
The Graal JIT compiler provides optimized performance for applications running on a Java Virtual Machine (JVM) through unique approaches to code analysis and optimization.
19
19
It includes multiple optimization algorithms (called “Phases”), such as aggressive inlining, polymorphic inlining, and others.
20
20
21
-
<!--
22
-
Add an anchor so that the JPG docs can link to a section on partial escape analysis.
23
-
-->
24
21
<aid="partial-escape-analysis"></a>
25
-
The Graal compiler can bring performance advantages for highly-abstracted programs.
26
-
For example, it includes a [partial-escape-analysis optimization](https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/phases/CEOptimization.java#L176){:target="_blank"} that can remove the costly allocations of certain objects.
22
+
The Graal compiler can bring performance advantages for highly-abstracted programs.
23
+
For example, it includes a partial-escape-analysis optimization that can remove the costly allocations of certain objects.
24
+
See the value [`PartialEscapeAnalysis`](https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/phases/CEOptimization.java#L176){:target="_blank"} in the `CEOptimization enum` in the GraalVM GitHub repository for more information.
27
25
The optimization determines when a new object is accessible outside a compilation unit and only allocates it on paths that "escape" the compilation unit (for example, if the object is passed as a parameter, stored in a field, or returned from a method).
28
26
This approach can greatly improve the performance of an application by reducing the number of heap allocations.
29
27
Code that uses more modern Java features such as Streams or Lambdas will see greater improvements in performance as this type of code involves a significant number of such non- or partially-escaping objects.
@@ -32,7 +30,8 @@ For more information on performance tuning, refer to [Graal JIT Compiler Configu
32
30
33
31
## Graph Compilation
34
32
35
-
To run guest programming languages (namely JavaScript, Python, and Ruby) in the same runtime as the host JVM-based language, the compiler works with a language-independent intermediate graph representation between the source language and the machine code to be generated. (For more information on language interoperability, see [Interoperability](README.md#interoperability).)
33
+
To run guest programming languages (namely JavaScript, Python, and Ruby) in the same runtime as the host JVM-based language, the compiler works with a language-independent intermediate graph representation between the source language and the machine code to be generated.
34
+
(For more information on language interoperability, see [Interoperability](README.md#interoperability).)
36
35
37
36
The graph can represent similar statements of different languages in the same way, such as "if" statements or loops, which makes it possible to mix languages in the same application.
38
37
The Graal compiler can then perform language-independent optimization and generate machine code on this graph.
0 commit comments