RFR: 8355798: Implement JEP 514: Ahead-of-Time Command Line Ergonomics [v8]
Vladimir Kozlov
kvn at openjdk.org
Wed May 14 16:08:55 UTC 2025
On Wed, 14 May 2025 06:16:15 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> This is the implementation of the draft [JEP: Ahead-of-time Command Line Ergonomics](https://bugs.openjdk.org/browse/JDK-8350022)
>>
>> - Implemented new flag `AOTCacheOutput`, which can be used to create an AOT cache using the "one-command workflow"
>> - Added processing of the `JAVA_AOT_OPTIONS` environment variable that can supply extra VM options when creating an AOT cache
>> - Added `%p` substitution for `AOTCache`, `AOTCacheOutput`, and `AOTConfiguration` options
>>
>> Please see the [JEP](https://bugs.openjdk.org/browse/JDK-8350022) and [CSR](https://bugs.openjdk.org/browse/JDK-8356010) for detailed specification.
>>
>> Examples:
>>
>>
>> # Create an AOT cache with a single command:
>> $ java -cp HelloWorld.jar -XX:AOTMode=record -XX:AOTCacheOutput=foo.aot HelloWorld
>> Hello World
>> Temporary AOTConfiguration recorded: foo.aot.config
>> Launching child process /usr/bin/java to assemble AOT cache foo.aot using configuration foo.aot.config
>> Picked up JAVA_TOOL_OPTIONS: -Djava.class.path=HelloWorld.jar -XX:AOTCacheOutput=foo.aot -XX:AOTConfiguration=foo.aot.config -XX:AOTMode=create
>> Reading AOTConfiguration foo.aot.config and writing AOTCache foo.aot
>> AOTCache creation is complete: foo.aot 10240000 bytes
>>
>> # Create logging file for the AOT cache assembly phase
>> $ export AOT_TOOL_COMMAND=-Xlog:cds:file=log.txt
>> $ java -cp HelloWorld.jar -XX:AOTMode=record -XX:AOTCacheOutput=foo.aot HelloWorld
>>
>>
>> Note: the child process is launched with Java API because the HotSpot native APIs are not sufficient (no way to set env vars for child process).
>
> Ioi Lam has updated the pull request incrementally with two additional commits since the last revision:
>
> - java.md updates from @rose00
> - Resolved differences with CSR JDK-8356010
Few comments.
src/hotspot/share/cds/cds_globals.hpp line 123:
> 121: product(ccstr, AOTCacheOutput, nullptr, \
> 122: "Write AOT cache into this file (overrides AOTCache when " \
> 123: "writing)") \
This looks not complete description. And "override AOTCache .." is confusing.
src/hotspot/share/cds/metaspaceShared.cpp line 1150:
> 1148: print_java_launcher(&ss);
> 1149: const char* cmd = ss.freeze();
> 1150: tty->print_cr("Launching child process %s to assemble AOT cache %s using configuration %s", cmd, AOTCacheOutput, AOTConfiguration);
I noticed that AOT produces outputs on TTY like this unconditionally. I think it is fine for development but for production we should use UL I think.
Was this discussed?
src/hotspot/share/runtime/arguments.cpp line 3060:
> 3058: }
> 3059:
> 3060: static JavaVMOption* get_last_aotmode_arg(const JavaVMInitArgs* args) {
I don't like that we pollute `Arguments` code with AOT specific flags processing.
Can we move this into `CDSConfig`? Both these 2 new methods.
But I will agree if you want to keep it here. It is not critical.
src/java.base/share/man/java.md line 4141:
> 4139: mode should be used only as a "fail-fast" debugging aid to check if your command-line
> 4140: options are compatible with the AOT cache. An alternative is to run your application with
> 4141: `-XX:AOTMode=auto -Xlog:cds,aot` to see if the AOT cache can be used or not.
`-Xlog:aot`
test/hotspot/jtreg/runtime/cds/appcds/aotFlags/AOTFlags.java line 166:
> 164: "-XX:-AOTClassLinking",
> 165: "-XX:AOTConfiguration=" + aotConfigFile,
> 166: "-Xlog:cds=debug",
`-Xlog:aot`
I assume JDK-8356595: "Convert -Xlog:cds to -Xlog:aot " will be pushed first.
-------------
PR Review: https://git.openjdk.org/jdk/pull/24942#pullrequestreview-2840679467
PR Review Comment: https://git.openjdk.org/jdk/pull/24942#discussion_r2089234532
PR Review Comment: https://git.openjdk.org/jdk/pull/24942#discussion_r2089261456
PR Review Comment: https://git.openjdk.org/jdk/pull/24942#discussion_r2089267274
PR Review Comment: https://git.openjdk.org/jdk/pull/24942#discussion_r2089274796
PR Review Comment: https://git.openjdk.org/jdk/pull/24942#discussion_r2089279429
More information about the core-libs-dev
mailing list