Skip to content

8306582: Remove MetaspaceShared::exit_after_static_dump()#14879

Closed
matias9927 wants to merge 9 commits intoopenjdk:masterfrom
matias9927:remove_exit_after_dump_8306582
Closed

8306582: Remove MetaspaceShared::exit_after_static_dump()#14879
matias9927 wants to merge 9 commits intoopenjdk:masterfrom
matias9927:remove_exit_after_dump_8306582

Conversation

@matias9927
Copy link
Contributor

@matias9927 matias9927 commented Jul 13, 2023

Currently we exit the VM after static dumping with MetaspaceShared::exit_after_static_dump().

 // We have finished dumping the static archive. At this point, there may be pending VM
 // operations. We have changed some global states (such as vmClasses::_klasses) that
 // may cause these VM operations to fail. For safety, forget these operations and
 // exit the VM directly.
 void MetaspaceShared::exit_after_static_dump() {
   os::_exit(0);
 } 

As the comment suggests, the VM state is altered when preparing and performing the static dump, so this change aims to prevent these state changes so the VM can exit normally after the static dump completes. There are three major aspects to this change:

  1. Since the resolved references array in the Constant Pool is altered when preparing for a static dump, a "scratch copy" is created and archived instead
  2. Symbols are sorted by address and have their hash recalculated. Similarly to point 1, the copies of the symbols that are to be archived have their hashes updated as opposed to the originals.
  3. The handling of -Xshare:dump during argument parsing such that the VM can continue and exit normally with an exit code of 0.

Verified with tier 1-9 tests.


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-8306582: Remove MetaspaceShared::exit_after_static_dump() (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14879

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 13, 2023

👋 Welcome back matsaave! 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 Jul 13, 2023

@matias9927 The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot

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

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Jul 13, 2023
@matias9927 matias9927 force-pushed the remove_exit_after_dump_8306582 branch 2 times, most recently from b4e06ff to cf270aa Compare July 14, 2023 02:47
@matias9927 matias9927 marked this pull request as ready for review July 14, 2023 18:07
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 14, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 14, 2023

Webrevs

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.

Hi Matias,

I'm not keen on having to teach the launcher about -Xshare:dump and that it is a terminal operation. But after looking into it I have to admit it is a cleaner and more consistent termination strategy. That said you need to be aware that this will now do a clean shutdown of the VM after the dump, so shutdown hooks will now run.

Lets see what core-libs folk think too.

Thanks.

@openjdk
Copy link

openjdk bot commented Jul 25, 2023

⚠️ @matias9927 This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@matias9927 matias9927 marked this pull request as draft July 25, 2023 14:17
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 25, 2023
@matias9927 matias9927 force-pushed the remove_exit_after_dump_8306582 branch from b479e64 to 2a27344 Compare July 25, 2023 14:24
@matias9927
Copy link
Contributor Author

I messed up a merge and pushed the incorrect contents to this PR. It will be temporarily reverted to a draft and force pushed to undo my mistake.

The existing comments should be addressed in the most recent commits.

@matias9927 matias9927 marked this pull request as ready for review July 25, 2023 18:43
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 25, 2023
Copy link
Member

@iklam iklam 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 overall. Some suggestions for code refactoring.

Copy link
Member

@iklam iklam 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. Just a couple of nits.

@openjdk
Copy link

openjdk bot commented Jul 27, 2023

@matias9927 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8306582: Remove MetaspaceShared::exit_after_static_dump()

Reviewed-by: iklam, alanb, ccheung

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 2 new commits pushed to the master branch:

  • bf70777: 8312181: CDS dynamic dump crashes when verifying unlinked class from static archive
  • 7ba8c69: 8312596: Null pointer access in Compile::TracePhase::~TracePhase after JDK-8311976

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 27, 2023
@matias9927 matias9927 requested a review from AlanBateman July 27, 2023 20:36
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

Updated launcher change looks fine.

Copy link
Member

@calvinccheung calvinccheung 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 overall. I have one question.

@matias9927
Copy link
Contributor Author

Thank you for the reviews @iklam, @calvinccheung, @dholmes-ora, and @AlanBateman!
/integrate

@openjdk
Copy link

openjdk bot commented Aug 2, 2023

Going to push as commit cff25dd.
Since your change was applied there have been 18 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 2, 2023
@openjdk openjdk bot closed this Aug 2, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 2, 2023
@openjdk
Copy link

openjdk bot commented Aug 2, 2023

@matias9927 Pushed as commit cff25dd.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants