Skip to content

8390907: Genshen: Improve mark loop performance - #32488

Open
earthling-amzn wants to merge 26 commits into
openjdk:masterfrom
earthling-amzn:simplify-reremember-during-mark
Open

8390907: Genshen: Improve mark loop performance#32488
earthling-amzn wants to merge 26 commits into
openjdk:masterfrom
earthling-amzn:simplify-reremember-during-mark

Conversation

@earthling-amzn

@earthling-amzn earthling-amzn commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

There are several small changes here that add up to a 10% to 12% reduction in mark times on specjbb2015.

  • Gate the re-remembering work on a template parameter so that only the remembered set scan closure needs to do it
  • Bias the affiliation byte array to eliminate a subtraction for every oop
  • Loosen the check on heap inclusion for decoded oops
  • Inline the card marking function
  • Inline age census add function
  • Test for two pointers being in the same region before testing if old points to young


Progress

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

Issue

  • JDK-8390907: Genshen: Improve mark loop performance (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 32488

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@earthling-amzn
earthling-amzn marked this pull request as draft August 21, 2026 22:11
@bridgekeeper

bridgekeeper Bot commented Aug 21, 2026

Copy link
Copy Markdown

👋 Welcome back wkemper! 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 commented Aug 21, 2026

Copy link
Copy Markdown

@earthling-amzn 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:

8390907: Genshen: Improve mark loop performance

Reviewed-by: kdnilsen, shade

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

At the time when this comment was updated there had been 7 new commits pushed to 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 hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Aug 21, 2026
@openjdk

openjdk Bot commented Aug 21, 2026

Copy link
Copy Markdown

@earthling-amzn The following labels will be automatically applied to this pull request:

  • hotspot-gc
  • 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 commented Aug 21, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-gc. This can be overridden with the /reviewers command.

// may visit class metadata that lives outside the heap so we cannot
// assume (or assert) that `p` is in old.
heap->old_generation()->mark_card_as_dirty(p);
} else if (GENERATION == GLOBAL && heap->has_affiliation(p, OLD_GENERATION) && heap->has_affiliation(obj, YOUNG_GENERATION)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be also predicated with DIRTY, or am I missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

REDIRTY is specifically for the remembered set scan. I have added more asserts to make this more clear. I also though about calling this parameter REREMEMBER, but it looked too weird.

inline bool is_write_card_dirty(HeapWord* p) const;
inline void mark_card_as_dirty(HeapWord* p);

void mark_card_as_dirty(HeapWord* p) const {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Functions like these really belong in .inline.hpp. Putting anything non-trivial in the .hpp risks circular dependencies that are hard to untangle.


public:
template<class T, ShenandoahGenerationType GENERATION>
template<class T, ShenandoahGenerationType GENERATION, bool REDIRTY = false>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We usually do not do default values for template parameters to force callers to decide whether they want it or not. Are there many instances that would require fixing if you drop = false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only one caller would set it true. The instantiations aren't spread all over the code base or anything, I was just trying to minimize changes in the PR.

@openjdk

openjdk Bot commented Aug 24, 2026

Copy link
Copy Markdown

@earthling-amzn 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 simplify-reremember-during-mark
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 Aug 24, 2026
@shipilev

Copy link
Copy Markdown
Member

In my runs, I also see ShenandoahAgeCensus::add not inlined. Have you seen it in yours?

@openjdk openjdk Bot removed the merge-conflict Pull request has merge conflict with target branch label Aug 24, 2026
void ShenandoahDirectCardMarkRememberedSet::mark_card_as_dirty(HeapWord* p) const {
size_t index = card_index_for_addr(p);
CardValue* bp = &(_card_table->write_byte_map())[index];
bp[0] = CardTable::dirty_card_val();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another question: does this write need to be conditional? We default to +UseCondCardMark to avoid contention on marks that are already dirty. Is the path we are optimizing benefits from the same optimization?

@earthling-amzn earthling-amzn Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For a young GC, the read card table will have been cleaned and then swapped with the write table, so the write table is clean here (which is why the rset closure redirties the cards at it scans the read table). During a global GC in generational mode, the rset is not scanned, but the tables are still swapped, so cards should also be clean here.

This function is also called during operations on the discovered list for reference processing, but I expect the write volume would not be high there as the card is only marked when an old reference is linked to a young reference.

@earthling-amzn
earthling-amzn marked this pull request as ready for review August 25, 2026 21:53
@openjdk openjdk Bot added the rfr Pull request is ready for review label Aug 25, 2026
@mlbridge

mlbridge Bot commented Aug 25, 2026

Copy link
Copy Markdown

Webrevs

@kdnilsen kdnilsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. Nice performance improvements.

@shipilev shipilev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks all right with a few nits.

* Copyright (c) 2015, 2020, Red Hat, Inc. All rights reserved.
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This moves dates backwards, so it does not look right.

Comment on lines +389 to +391
if (ShenandoahHeapRegion::is_in_same_region(maybe_old, maybe_young)) {
return false;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for my understanding. This is a narrower check than we can do? I would have tried to check that region affiliations are different. But that performs access to affiliation bitmap, so that's why we do this address-only check, right?

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Aug 26, 2026
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 ready Pull request is ready to be integrated rfr Pull request is ready for review shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants