-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8327495: Print more warning with -Xshare:auto when CDS fails to use archive #24889
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
base: master
Are you sure you want to change the base?
8327495: Print more warning with -Xshare:auto when CDS fails to use archive #24889
Conversation
👋 Welcome back ccheung! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@calvinccheung The following label will be automatically applied to this pull request:
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. |
Webrevs
|
void MetaspaceShared::report_loading_error(const char* message) { | ||
|
||
if (SharedArchiveFile != nullptr) { | ||
log_error(cds)("An error has occurred while processing the %s.", CDSConfig::type_of_archive_being_loaded()); | ||
if (message != nullptr) { | ||
log_error(cds)("%s", message); | ||
} | ||
} else { | ||
log_info(cds)("An error has occurred while processing the %s.", CDSConfig::type_of_archive_being_loaded()); | ||
if (message != nullptr) { | ||
log_info(cds)("%s", message); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AOT workflow doesn't use the SharedArchiveFile
flag. I think to detect that we are not using the default archive, we should do this:
bool CDSConfig::is_using_only_default_archive() {
return is_using_archive() &&
input_static_archive_path() != nullptr &&
default_archive_path() != nullptr &&
strcmp(input_static_archive_path(), default_archive_path()) == 0 &&
input_dynamic_archive_path() == nullptr;
}
I think the printing can be simplified like this to avoid duplication:
// If the user doesn't specify any CDS options, we will try to load the default CDS archive, which
// may fail due to incompatible VM options. Print at the info level to avoid excessive verbosity.
// However, if the user has specified a CDS archive (or AOT cache), they would be interested in
// knowing that the loading fails, so we print at the error level.
Log(cds) log;
LogStream ls_error(log.error());
LogStream ls_info(log.warning());
LogStream& ls = CDSConfig::is_using_only_default_archive() ? ls_info : ls_error;
ls.print_cr("An error has occurred while processing the %s.", CDSConfig::type_of_archive_being_loaded());
if (message != nullptr) {
ls_print(cds)("%s", message);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've incorporated your suggestion with some slight adjustment. For the CDSConfig::is_using_only_default_archive()
, it needs to account for dumping a classlist during JDK build time.
if (!is_using_archive()) { | ||
// During JDK build when dumping a classlist (DumpLoadedClassList), exclude error | ||
// message from the classlist as it interferes with the default CDS archive creation. | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check the Makefiles, and the situation you are trying to avoid is this part in make/GenerateLinkOptData.gmk:
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.SortClasslist [email protected] > $@
After adding -Xlog:cds=/tmp/foo.txt
to the above command, I get the following in the log file:
[0.004s][info][cds] trying to map /jdk3/bld/tin/support/interim-image/lib/server/classes.jsa
[0.004s][info][cds] Specified shared archive file not found (/jdk3/bld/tin/support/interim-image/lib/server/classes.jsa)
[0.004s][info][cds] An error has occurred while processing the shared archive file.
[0.004s][info][cds] Loading static archive failed.
[0.004s][error][cds] An error has occurred while processing the shared archive file.
[0.004s][error][cds] Unable to map shared spaces
I think the !is_using_archive()
shouldn't be in this function. Instead it should be in MetaspaceShared::report_loading_error()
:
LogStream& ls = (!CDSConfig::is_using_archive()) || CDSConfig::is_using_only_default_archive() ? ls_info : ls_error;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that with AOT class linking, we need better diagnostics. E.g.:
$ java -cp HelloWorld.jar -XX:AOTMode=record -XX:AOTConfiguration=hw.aotconfig HelloWorld
Hello World
AOTConfiguration recorded: hw.aotconfig
$ java -cp HelloWorld.jar -XX:AOTMode=create -XX:AOTCache=hw.aot -XX:AOTConfiguration=hw.aotconfig
Reading AOTConfiguration hw.aotconfig and writing AOTCache hw.aot
AOTCache creation is complete: hw.aot 9682944 bytes
$ java --add-modules=java.base -cp HelloWorld.jar -XX:AOTMode=on -XX:AOTCache=hw.aot HelloWorld
[0.005s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
Error occurred during initialization of VM
Unable to use AOT cache.
It's not clear why "full module graph is not used". I added the following patch on to of your PR:
Now there's a better explanation:
$ java --add-modules=java.base -cp HelloWorld.jar -XX:AOTMode=on -XX:AOTCache=hw.aot HelloWorld
[0.017s][error][cds] An error has occurred while processing the AOT cache. Run with -Xlog:cds for details.
[0.017s][error][cds] Mismatched values for property jdk.module.addmods: java.base specified during runtime but not during dump time
[0.017s][error][cds] Disabling optimized module handling
[0.017s][error][cds] CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used.
Error occurred during initialization of VM
Unable to use AOT cache.
Could you check other cases where the FMG is disabled and change their error reporting to use MetaspaceShared::report_loading_error()
Also, we have a few messages that says: "CDS archive has aot-linked classes ...". I think these should be changed to use CDSConfig::type_of_archive_being_loaded()
.
Before this change, if the
-Xshare:auto
is specified with a CDS archive, the user won't see the following error message when the archive has failed to load:An error has occurred while processing the the shared archive file.
This change will print the above error message if the
-Xshare:auto
is specified and the archive is not the default one.Several existing
log_ino(cds)()
calls have been changed to calling the new functionMetaspaceShared::report_loading_error()
. Also modified couple of tests to check the above error message is printed.Passed tiers 1 - 3 testing.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24889/head:pull/24889
$ git checkout pull/24889
Update a local copy of the PR:
$ git checkout pull/24889
$ git pull https://git.openjdk.org/jdk.git pull/24889/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24889
View PR using the GUI difftool:
$ git pr show -t 24889
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24889.diff
Using Webrev
Link to Webrev Comment