Skip to content

Commit df57c97

Browse files
committed
8348515: Add docs for -XX:AOT* options in java man pages
Reviewed-by: kvn Backport-of: 46f48e4
1 parent 2a1a416 commit df57c97

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

src/java.base/share/man/java.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,6 +4037,110 @@ JVM will execute without loading any CDS archives. In addition, if
40374037
you try to create a CDS archive with any of these 3 options specified,
40384038
the JVM will report an error.
40394039

4040+
## Ahead-of-Time Cache
4041+
4042+
The JDK supports ahead-of-time (AOT) optimizations that can be performed before an
4043+
application is executed. One example is Class Data Sharing (CDS), as described above,
4044+
that parses classes ahead of time. AOT optimizations can improve the start-up and
4045+
warm-up performance of Java applications.
4046+
4047+
The Ahead-of-Time Cache (AOTCache) is a container introduced in JDK 24 for
4048+
storing artifacts produced by AOT optimizations. The AOTCache currently contains
4049+
Java classes and heap objects. The plans is to include other types of artifacts,
4050+
such as execution profiles and compiled methods, in future JDK releases.
4051+
4052+
An AOTCache is specific to a combination of the following:
4053+
4054+
- A particular application (as expressed by `-classpath`, `-jar`, or `--module-path`.)
4055+
- A particular JDK release.
4056+
- A particular OS and CPU architecture.
4057+
4058+
If any of the above changes, you must recreate the AOTCache.
4059+
4060+
The deployment of the AOTCache is divided into three phases:
4061+
4062+
- **Training:** We execute the application with a representative work-load
4063+
to gather statistical data that tell us what artifacts should be included
4064+
into the AOTCache. The data are saved in an *AOT Configuration* file.
4065+
4066+
- **Assembly:** We use the AOT Configuration file to produce an AOTCache.
4067+
4068+
- **Production:** We execute the application with the AOTCache for better
4069+
start-up and warm-up performance.
4070+
4071+
The AOTCache can be used with the following command-line options:
4072+
4073+
`-XX:AOTCache:=`*cachefile*
4074+
: Specifies the location of the AOTCache. The standard extension for *cachefile* is `.aot`.
4075+
If `-XX:AOTCache` is specified but `-XX:AOTMode` is not specified,
4076+
then `AOTMode` will be given the value of `auto`.
4077+
4078+
`-XX:AOTConfiguration:=`*configfile*
4079+
: Specifies the AOT Configuration file for the JVM to write to or read from.
4080+
This option can be used only with `-XX:AOTMode=record` and `-XX:AOTMode=create`.
4081+
The standard extension for *configfile* is `.aotconfig`.
4082+
4083+
`-XX:+AOTMode:=`*mode*
4084+
: *mode* must be one of the following: `off`, `record`, `create`, `auto`, or `on`.
4085+
4086+
- `off`: AOTCache is not used.
4087+
4088+
- `record`: Execute the application in the Training phase.
4089+
`-XX:AOTConfiguration=`*configfile* must be specified. The JVM gathers
4090+
statistical data and stores them into *configfile*.
4091+
4092+
- `create`: Perform the Assembly phase. `-XX:AOTConfiguration=`*configfile*
4093+
and `-XX:AOTCache=`*cachefile* must be specified. The JVM reads the statistical
4094+
data from *configfile* and writes the optimization artifacts into *cachefile*.
4095+
Note that the application itself is not executed in this phase.
4096+
4097+
- `auto` or `on`: These modes should be used in the Production phase.
4098+
If `-XX:AOTCache=`*cachefile* is specified, the JVM tries to
4099+
load *cachefile* as the AOTCache. Otherwise, the JVM tries to load
4100+
a *default CDS archive* from the JDK installation directory as the AOTCache.
4101+
4102+
The loading of an AOTCache can fail for a number of reasons:
4103+
4104+
- You are trying to use the AOTCache with an incompatible application, JDK release,
4105+
or OS/CPU.
4106+
4107+
- The specified AOTCache file does not exist or is not accessible.
4108+
4109+
- Incompatible JVM options are used (for example, certain JVMTI options).
4110+
4111+
Since AOTCache is an optimization feature, there's no guarantee that it will be
4112+
compatible with all possible JVM options. See [JEP 483](https://openjdk.org/jeps/483),
4113+
section **Consistency of training and subsequent runs** for a representitive
4114+
list of scenarios that may be incompatible with the AOTCache for JDK 24.
4115+
4116+
These scenarios usually involve arbitrary modification of classes for diagnostic
4117+
purposes and are typically not relevant for production environments.
4118+
4119+
When the AOTCache fails to load:
4120+
4121+
- If `AOTMode` is `auto`, the JVM will continue execution without using the
4122+
AOTCache. This is the recommended mode for production environments, especially
4123+
when you may not have complete control of the command-line (e.g., your
4124+
application's launch script may allow users to inject options to the command-line).
4125+
This allows your application to function correctly, although sometimes it may not
4126+
benefit from the AOTCache.
4127+
4128+
- If `AOTMode` is `on`, the JVM will print an error message and exit immediately. This
4129+
mode should be used only as a "fail-fast" debugging aid to check if your command-line
4130+
options are compatible with the AOTCache. An alternative is to run your application with
4131+
`-XX:AOTMode=auto -Xlog:cds` to see if the AOTCache can be used or not.
4132+
4133+
`-XX:+AOTClassLinking`
4134+
: If this options is specified with `-XX:AOTMode=create`, the JVM will perform more
4135+
advanced optimizations (such as ahead-of-time resolution of invokedynamic instructions)
4136+
when creating the AOTCache. As a result, the appication will see further improvements
4137+
in start-up and warm-up performance.
4138+
4139+
Using `-XX:+AOTClassLinking` will impose further restrictions on command-line options
4140+
that can be used in the Production phase. Please see [JEP 483](https://openjdk.org/jeps/483) for a
4141+
detailed discussion of `-XX:+AOTClassLinking` and its restrictions.
4142+
4143+
40404144
## Performance Tuning Examples
40414145

40424146
You can use the Java advanced runtime options to optimize the performance of

0 commit comments

Comments
 (0)