Skip to content
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

8290700: Optimize AArch64 nmethod entry barriers #9574

Closed

Conversation

fisk
Copy link
Contributor

@fisk fisk commented Jul 20, 2022

The original nmethod entry barrier supported only concurrent patching of data and was used by ZGC to solve concurrent class unloading problems. Now it is starting to see more uses. Notably, loom uses nmethod entry barriers to figure out what nmethods have been seen on-stack, needed to remove nmethods safely. However, the concurrent data patching variation was too slow for loom (showed a few regressions), so I brought over a faster nmethod entry barrier that we use in the generational ZGC repo, which additionally handles concurrent patching of data and instructions, which is needed there.
However, I still see some small regressions. So for the uses in loom, the classic GCs don't really patch anything interesting concurrently. This leads to the following possible enhancements to improve the situation:

  1. Make a dedicated nmethod entry barrier for GCs that don't patch data nor code concurrently, consisting of basically only a conditional branch. There is no need to penalize STW GCs with seat belts protecting against concurrent races that simply do not exist.

  2. Move the "guard" word and call into the VM trampoline, to an out-of-line stub towards the end of the nmethod, ensuring instruction caches are not polluted by non-hot instructions at the nmethod entry. Some machines also better optimize the branch-not-taken path of conditional branches.

With these optimizations, the small regressions did go away.


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

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9574

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 20, 2022

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

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 20, 2022
@openjdk
Copy link

openjdk bot commented Jul 20, 2022

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

  • hotspot
  • shenandoah

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 shenandoah shenandoah-dev@openjdk.org labels Jul 20, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 20, 2022

Webrevs

@fisk
Copy link
Contributor Author

fisk commented Jul 20, 2022

Note that this PR is dependent on #9569

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/9569 to master July 22, 2022 14:49
@openjdk-notifier
Copy link

The dependent pull request has now been integrated, and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout 8290700_faster_aarch64_entry_barriers
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented Jul 22, 2022

@fisk 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 8290700_faster_aarch64_entry_barriers
git fetch https://git.openjdk.org/jdk 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 Jul 22, 2022
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Jul 22, 2022
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 reasonable to me.
Someone familiar with aarch64 code have to review it.

@openjdk
Copy link

openjdk bot commented Jul 22, 2022

@fisk 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:

8290700: Optimize AArch64 nmethod entry barriers

Reviewed-by: kvn, dlong

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:

  • ef8486a: 8286270: [java.desktop] Replace color search in XColors with a switch statement
  • 62f2263: 8290861: Remove unused field URLJarFile.BUF_SIZE

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 22, 2022
@fisk
Copy link
Contributor Author

fisk commented Jul 22, 2022

Thanks for the review, @vnkozlov!

}
}
ShouldNotReachHere();
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this function is not performance-critical. If it was, then we could consider adding a new field to the nmethod to keep track of the offset for the guard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I thought about adding a new entry to CodeOffsets, but it seemed like this C2-only AArch64-only detail seemed a bit noisy in the shared code then. And it didn't seem warranted, given how cold this path is by design.

@fisk
Copy link
Contributor Author

fisk commented Jul 23, 2022

Thanks for the review @dean-long!

@fisk
Copy link
Contributor Author

fisk commented Jul 25, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Jul 25, 2022

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

  • 852e71d: 8290870: NMT: Increase MallocSiteTable size and allocate it only when needed
  • 0599a05: 8290900: Build failure with Clang 14+ due to function warning attribute
  • 987656d: 8289471: Issue in Initialization of keys in ErrorMsg.java and XPATHErrorResources.java
  • 2660a92: 8290893: ProblemList java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload
  • ef8486a: 8286270: [java.desktop] Replace color search in XColors with a switch statement
  • 62f2263: 8290861: Remove unused field URLJarFile.BUF_SIZE

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 25, 2022
@openjdk openjdk bot closed this Jul 25, 2022
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 25, 2022
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 25, 2022
@openjdk
Copy link

openjdk bot commented Jul 25, 2022

@fisk Pushed as commit 228e8e9.

💡 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
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated shenandoah shenandoah-dev@openjdk.org
3 participants