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

8280917: Simplify G1ConcurrentRefineThread activation #7282

Closed
wants to merge 6 commits into from

Conversation

kimbarrett
Copy link

@kimbarrett kimbarrett commented Jan 31, 2022

Please review this change to to G1ConcurrentRefineThreads to simplify the
activation mechanism.

We split the class into two subclasses, one for the "primary" refinement
thread and another class for the remaining refinement threads.

The secondary threads are changed to use Monitor-based waits and notifications
with a supporting request flag.

The primary thread uses an atomic activation threshold that also serves as "is
running" state. This activation threshold is used by the write barrier
support to determine whether the thread's semaphore needs to be signaled.
That threshold is now in the primary refinement thread rather than in the
dirty card queue set to simplify threshold management and somewhat reduce
coupling.

Testing:
mach5 tier1-3

Manual tests with refinement thread logging enabled to verify expected
activations occur.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8280917: Simplify G1ConcurrentRefineThread activation

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7282/head:pull/7282
$ git checkout pull/7282

Update a local copy of the PR:
$ git checkout pull/7282
$ git pull https://git.openjdk.java.net/jdk pull/7282/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7282

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7282.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 31, 2022

👋 Welcome back kbarrett! 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 openjdk bot added the rfr Pull request is ready for review label Jan 31, 2022
@openjdk
Copy link

openjdk bot commented Jan 31, 2022

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

  • hotspot-gc

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.

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Jan 31, 2022
@mlbridge
Copy link

mlbridge bot commented Jan 31, 2022

Webrevs

// the primary thread if needed. Non-GC safepoints are expected to
// rarely (if ever) dirty cards, so defer activation to a post-safepoint
// notification.
if (SafepointSynchronize::is_at_safepoint()) {
Copy link
Author

Choose a reason for hiding this comment

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

@walulyai noticed that this test was backward. Difference in testing is often surprisingly subtle, I suspect because there's enough other wonkiness in the refinement thread control to often mask the effect. This change as a whole is intended as a step toward fixing that. I'm sure glad Ivan spotted this now though.

Copy link
Author

Choose a reason for hiding this comment

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

I re-ran tests and ran some additional with this mistake fixed. No problems encountered. I also did some better performance testing. specjbb2015 with options that will trigger the need for more concurrent refinement was unchanged between baseline and with the above fixed. Having the test backward produced a 6-7% regression. Thanks again Ivan.

Copy link
Member

@walulyai walulyai left a comment

Choose a reason for hiding this comment

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

Lgtm!

@openjdk
Copy link

openjdk bot commented Feb 3, 2022

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

8280917: Simplify G1ConcurrentRefineThread activation

Reviewed-by: iwalulya, sjohanss

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 1 new commit pushed to the master branch:

  • f2a9627: 8279329: Remove hardcoded IPv4 available policy on Windows

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 Feb 3, 2022
Copy link
Contributor

@kstefanj kstefanj 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 small comments.


// Called when no refinement work found for this thread.
// Returns true if should deactivate.
bool maybe_deactivate(bool more_work);
// precondition: this is the current thread.
virtual bool maybe_deactivate() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the name is pre-existing, but I've always found the naming it a bit odd. Or we usually call thing like this should_deactivate(). If you prefer keeping the old name I'm fine with it, just wanted to mention it since we are changing the code.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not especially fond that name, but a should_ prefix would incorrectly suggest it's "just" a predicate, but it has side effects. I have some further changes coming that might do things a bit differently. I'll keep the naming in mind.

class G1PrimaryConcurrentRefineThread final : public G1ConcurrentRefineThread {
Semaphore _notifier;
DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0);
volatile size_t _threshold;
Copy link
Contributor

Choose a reason for hiding this comment

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

Might make sense to add some additional comment for the threshold, similar to the description you have in the PR summary:

The primary thread uses an atomic activation threshold that also serves as "is
running" state. This activation threshold is used by the write barrier
support to determine whether the thread's semaphore needs to be signaled.

Copy link
Author

Choose a reason for hiding this comment

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

I meant to do that, and then forgot. Thanks for point it out. I'll add it before pushing.

@kimbarrett
Copy link
Author

Thanks @walulyai and @kstefanj for reviews.

@kimbarrett
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 8, 2022

Going to push as commit 861f279.
Since your change was applied there has been 1 commit pushed to the master branch:

  • f2a9627: 8279329: Remove hardcoded IPv4 available policy on Windows

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 8, 2022

@kimbarrett Pushed as commit 861f279.

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

@kimbarrett kimbarrett deleted the split-crt branch February 8, 2022 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants