Skip to content

8361055: Serial: Inline SerialHeap::process_roots #26038

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

albertnetymk
Copy link
Member

@albertnetymk albertnetymk commented Jun 30, 2025

Refactor roots processing in Serial (young-gc and full-gc) to clean up the control-flow and make is clearer what roots and closures are used in each context.

Test: tier1-8


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-8361055: Serial: Inline SerialHeap::process_roots (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26038

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 30, 2025

👋 Welcome back ayang! 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 Jun 30, 2025

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

8361055: Serial: Inline SerialHeap::process_roots

Reviewed-by: stefank

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 36 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 changed the title 8361055 8361055: Serial: Inline SerialHeap::process_roots Jun 30, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 30, 2025
@openjdk
Copy link

openjdk bot commented Jun 30, 2025

@albertnetymk 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 Jun 30, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 30, 2025

Webrevs

Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

Not really convinced about this change: if there is need to add a root now, you need to look at three places instead of one.
The parameter to select particular additional roots seems clear enough to me.

Comment on lines 618 to 619
_old_gen->scan_old_to_young_refs(_old_gen->space()->top());
// During young-gc, visit all (strong+weak) clds with the same closure.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_old_gen->scan_old_to_young_refs(_old_gen->space()->top());
// During young-gc, visit all (strong+weak) clds with the same closure.
_old_gen->scan_old_to_young_refs(_old_gen->space()->top());
// During young-gc, visit all (strong+weak) clds with the same closure.

I also wonder if the previous placement of scan_old_to_young_refs after the other roots were intentional and this PR changes that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both orderings are fine. (ScavengeRootsTask processes old-to-young pointers first). I changed that to avoid a local variable. Can revert it back if you prefers that.

Copy link
Member

Choose a reason for hiding this comment

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

OK. I understand. It could be worth adding a comment explaining that we're scanning objects that were old before relocation started. FWIW, if you want to keep it at the top then I think you can get rid of "_old_gen->space()->top()" from this function and extract it inside scan_old_to_young_refs instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comment and inlined space()->top() to the callee.

!NMethodToOopClosure::FixRelocations,
true);

ClassLoaderDataGraph::always_strong_cld_do(&follow_cld_closure);
Copy link
Member

Choose a reason for hiding this comment

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

The old code treated !ClassUnloading differently. It's not clear to me why this change is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

always_strong_cld_do does ClassUnloading checking internally.

Semantically, for full-gc marking, we process always-strong clds only. (Ofc, if class unloading is off, all clds are always-strong.)

Copy link
Member

Choose a reason for hiding this comment

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

I see.

After having not looked at this for a while I find the "always" part of the name both redundant and even slightly misleading. This function could be named "strong_cld_do" (or even strong_clds_do, but the other functions are also miss the s). This could be a cleanup for the future.

@albertnetymk
Copy link
Member Author

Not really convinced about this change: if there is need to add a root now, you need to look at three places instead of one.

That's true and IMO desirable. If a new kind of roots are added, we need to think carefully, how (young/old) gcs and different phases process it.

The parameter to select particular additional roots seems clear enough to me.

Well, I guess it's different style. For example, with this refactoring (untanglement), I noticed that for young-gc, Threads::oops_do doesn't need the second argument (nmethod_cl can be set to null) to skip nmethod scanning. I suspect this redundancy will be hard to spot in the original style. (I will do that after this refactoring.)

@stefank
Copy link
Member

stefank commented Jun 30, 2025

Not really convinced about this change: if there is need to add a root now, you need to look at three places instead of one.

That's true and IMO desirable. If a new kind of roots are added, we need to think carefully, how (young/old) gcs and different phases process it.

The parameter to select particular additional roots seems clear enough to me.

Well, I guess it's different style. For example, with this refactoring (untanglement), I noticed that for young-gc, Threads::oops_do doesn't need the second argument (nmethod_cl can be set to null) to skip nmethod scanning. I suspect this redundancy will be hard to spot in the original style. (I will do that after this refactoring.)

FWIW, I tend to like these kind of untanglements. We've gone back and forth w.r.t. the style in the root processors and making them more generic tends to make the code harder to understand, IMHO.

Copy link
Member

@stefank stefank left a comment

Choose a reason for hiding this comment

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

To me this is OK. I'll leave it up to you and other reviewers to determine if this change should be made or not.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 30, 2025
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
Development

Successfully merging this pull request may close these issues.

3 participants