Skip to content

8355638: Allow -Xlog:aot to be used as an alias for -Xlog:cds when using AOT cache #24895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

iklam
Copy link
Member

@iklam iklam commented Apr 26, 2025

Specification:

When the JVM is started with any of the following options: AOTCache, AOTCacheOutput, AOTConfiguration, AOTMode:

  • Any -Xlog options that starts with the aot tag should also match any LogTagSets whose first tag is LogTag::_cds
  • When printing a LogTagSet whose first tag is LogTag::_cds, if its tags decoration is to be printed, then the first tag in the decoration should be printed as aot.

Examples:

Control case -- this is an example of an old "cds" log. The decoration should be printed as "cds" to be backwards compatible

$ java -Xshare:auto -Xlog:cds --version | grep trying
[0.003s][info][cds] trying to map /jdk3/bld/vox/images/jdk/lib/server/classes.jsa

"aot" can be used to select the "cds" log, but the log will be printed with "aot" as its decoration

$ java -XX:AOTMode=auto -Xlog:aot --version | grep trying
[0.015s][info][aot] trying to map /jdk3/bld/vox/images/jdk/lib/server/classes.jsa

When using new -XX:AOT flags, even if you specify -Xlog:cds, the output will use "aot" decoration

$ java -XX:AOTMode=auto -Xlog:cds --version | grep tryi
[0.004s][info][aot] trying to map /jdk3/bld/vox/images/jdk/lib/server/classes.jsa

When using new -XX:AOT flags, error messages should be logged with "aot" decoration even when no -Xlog flags are specified

$ java -XX:AOTMode=auto -XX:AOTCache=nofile.aot --version
[0.009s][error][aot] An error has occurred while processing the AOT cache. Run with -Xlog:aot for details.
[0.009s][error][aot] Loading AOT cache failed: nofile.aot
java 25-internal 2025-09-16
Java(TM) SE Runtime Environment (build 25-internal-adhoc.iklam.vox)
Java HotSpot(TM) 64-Bit Server VM (build 25-internal-adhoc.iklam.vox, mixed mode)

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8355638: Allow -Xlog:aot to be used as an alias for -Xlog:cds when using AOT cache (Enhancement - P4) ⚠️ Issue is not open.

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24895/head:pull/24895
$ git checkout pull/24895

Update a local copy of the PR:
$ git checkout pull/24895
$ git pull https://git.openjdk.org/jdk.git pull/24895/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24895

View PR using the GUI difftool:
$ git pr show -t 24895

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24895.diff

Using Webrev

Link to Webrev Comment

@iklam iklam force-pushed the 8355638-xlog-aot-as-alias-for-xlog-cds branch from c32b6f7 to 8ed2bf5 Compare April 26, 2025 05:56
@bridgekeeper
Copy link

bridgekeeper bot commented Apr 26, 2025

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 26, 2025

@iklam This change is no longer ready for integration - check the PR body for details.

@openjdk
Copy link

openjdk bot commented Apr 26, 2025

@iklam The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

iklam added 2 commits April 25, 2025 23:00
…w workflow; added PrintCDSLogsAsAOTLogs diagnostic flag
@@ -21,6 +21,8 @@
* questions.
*
*/

#include "cds/cds_globals.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wrap this include in INCLUDE_CDS as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually don't put includes around cds header files (there are lots of them). These header are compatible whether INCLUDE_CDS is enabled or not.

@openjdk openjdk bot changed the title 8355638: Allow -Xlog:aot to be used as an alias for -Xlog:cds 8355638: Allow -Xlog:aot to be used as an alias for -Xlog:cds when using AOT cache May 6, 2025
@iklam iklam marked this pull request as ready for review May 6, 2025 22:28
@openjdk openjdk bot added the rfr Pull request is ready for review label May 6, 2025
@mlbridge
Copy link

mlbridge bot commented May 6, 2025

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 7, 2025
Copy link
Contributor

@jdksjolen jdksjolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK!

Comment on lines 186 to 189
if (PrintCDSLogsAsAOTLogs && _ntags > 0 && _tags[0] == LogTag::_aot && ts.tag(0) == LogTag::_cds) {
// Consider it a match
i ++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap this in INCLUDE_CDS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 7, 2025
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found typo UL ouput in filemap.cpp: arrow_klass_pointer_bits

@openjdk
Copy link

openjdk bot commented May 8, 2025

@iklam this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8355638-xlog-aot-as-alias-for-xlog-cds
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 8, 2025
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR seems to be combining a few things:

  • establishing the "aliasing" mechanism
  • changing some logging statements from CDS to AOT (which already has its own JBS issue IIRC)
  • adding new configuration error checking

It may be cleaner to keep these distinct.

I'm also wondering whether we can have a more direct, and general-purpose, aliasing mechanism, that simply connects two tags as aliases such that enabling one enables the other and changes it's printed name? That would be less intrusive than putting this AOT specific logic (which is still an experiment/preview feature isn't it?) into the UL code.

#if INCLUDE_CDS
if (PrintCDSLogsAsAOTLogs && _ntags > 0 && _tags[0] == LogTag::_aot && ts.tag(0) == LogTag::_cds) {
// Consider it a match
i ++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
i ++;
i++;

@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label May 8, 2025
@iklam
Copy link
Member Author

iklam commented May 8, 2025

This PR seems to be combining a few things:

  • establishing the "aliasing" mechanism
  • changing some logging statements from CDS to AOT (which already has its own JBS issue IIRC)

The logs that are changed are of the pattern cds+aot+link. UL cannot accept aot+aot+link:

$ java -Xlog:aot+aot --version
[0.000s][error][logging] Log selection contains duplicates of tag aot.
Invalid -Xlog option '-Xlog:aot+aot', see error log for details.

Therefore, these logs must be changed, or else they cannot be accessed using the -Xlog:aot alias. I didn't change any other cds logs.

  • adding new configuration error checking

Do you mean the changes in filemap.cpp? I've reverted them.

It may be cleaner to keep these distinct.

I'm also wondering whether we can have a more direct, and general-purpose, aliasing mechanism, that simply connects two tags as aliases such that enabling one enables the other and changes it's printed name? That would be less intrusive than putting this AOT specific logic (which is still an experiment/preview feature isn't it?) into the UL code.

I am not sure if we want a general-purpose, aliasing mechanism. I think it will just be confusing for both HotSpot developers and users.

I see this exercise as a one off -- a long time feature that gets a new name. Once the -Xlog:cds logs are all removed, this aliasing mechanism (a dozen or so lines of code) will be completely removed.

AOT is not an experiment/preview feature. It's a product feature in JEP 483 which was introduced in JDK 24.

@stefank
Copy link
Member

stefank commented May 8, 2025

This seems like a hack in the UL system. Did you consider confining this in the CDS / AOT code instead?

Something like this pseudo code:

bool aot_log_is_enabled(Level, ...) {
  return log_is_enabled(Level, aot, link) ||
         log_is_enabled(Level, cds, link);
}
void aot_log_info(...) {}
...
if (aot_log_is_enabled(Info, link) {
  ResourceMark rm;
  aot_log_info(link)("%s %s %p", class_category_name(ik), ik->external_name(), ik);
}

@iklam
Copy link
Member Author

iklam commented May 8, 2025

This seems like a hack in the UL system. Did you consider confining this in the CDS / AOT code instead?

Something like this pseudo code:

bool aot_log_is_enabled(Level, ...) {
  return log_is_enabled(Level, aot, link) ||
         log_is_enabled(Level, cds, link);
}
void aot_log_info(...) {}
...
if (aot_log_is_enabled(Info, link) {
  ResourceMark rm;
  aot_log_info(link)("%s %s %p", class_category_name(ik), ik->external_name(), ik);
}

OK I'll try that. I think most cds logs are obscure and can be changed to aot. I'll implement a few macros for the style you suggested above, and use them on the "user facing" logs -- e.g, those that report errors for trouble shooting purposes.

@iklam
Copy link
Member Author

iklam commented May 9, 2025

This seems like a hack in the UL system. Did you consider confining this in the CDS / AOT code instead?
Something like this pseudo code:

bool aot_log_is_enabled(Level, ...) {
  return log_is_enabled(Level, aot, link) ||
         log_is_enabled(Level, cds, link);
}
void aot_log_info(...) {}
...
if (aot_log_is_enabled(Info, link) {
  ResourceMark rm;
  aot_log_info(link)("%s %s %p", class_category_name(ik), ik->external_name(), ik);
}

OK I'll try that. I think most cds logs are obscure and can be changed to aot. I'll implement a few macros for the style you suggested above, and use them on the "user facing" logs -- e.g, those that report errors for trouble shooting purposes.

@stefank @jdksjolen could you check out #25136 for the new approach?

That PR has much more changes than this PR, but we need to change those eventually anyway to complete the [cds] to [aot] transition.

@jdksjolen
Copy link
Contributor

This seems like a hack in the UL system. Did you consider confining this in the CDS / AOT code instead?
Something like this pseudo code:

bool aot_log_is_enabled(Level, ...) {
  return log_is_enabled(Level, aot, link) ||
         log_is_enabled(Level, cds, link);
}
void aot_log_info(...) {}
...
if (aot_log_is_enabled(Info, link) {
  ResourceMark rm;
  aot_log_info(link)("%s %s %p", class_category_name(ik), ik->external_name(), ik);
}

OK I'll try that. I think most cds logs are obscure and can be changed to aot. I'll implement a few macros for the style you suggested above, and use them on the "user facing" logs -- e.g, those that report errors for trouble shooting purposes.

@stefank @jdksjolen could you check out #25136 for the new approach?

That PR has much more changes than this PR, but we need to change those eventually anyway to complete the [cds] to [aot] transition.

Personally, I was fine with a temporary hack. Now, we do have a 'proper' solution, so let's go with that.

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 14, 2025
@iklam iklam closed this May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime [email protected] merge-conflict Pull request has merge conflict with target branch rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

5 participants