Skip to content

Conversation

@rkennke
Copy link
Contributor

@rkennke rkennke commented Aug 15, 2024

Currently, the full-GC modes of Serial, Parallel, Shenandoah and G1 GCs are forwarding objects by over-writing the object header with the new object location. Unfortunately, for compact object headers (JDK-8294992) this would not work, because the crucial class information is also stored in the header, and we could no longer iterate over objects until the headers would be restored. Also, the preserved-headers tables would grow quite large because now all headers would be 'interesting' and would have to be preserved.

I propose to use an alternative encoding for full-GC (sliding-GC) so that the forwarding information fits into the lowest 32 bits of the header. The encoding is similar to compressed-oops encoding: it basically subtracts the forwardee address from the heap-base, shifts that difference into the right place, and sets the lowest two bits (to indicate 'forwarded' state as usual).

The current implementation preserves the upper 32 bits of the mark-word. This leaves 30 bits for encoding the forwardee, enough for 8GB of heap. As soon as we get Tiny Class-Pointers (planned as part of compact headers upstreaming), we only need 22 bits for the narrow Klass*, and can use 40 bits for forwardee encoding. That's enough for 8TB of heap. If somebody wants to run with larger heap than this, compact headers would be disabled. This change also adds some infrastructure to configure the flags, with the code commented out, to illustrate the intended use.

An earlier approach to address the problem has been proposed in #13582. This has been implemented under the assumption that we would only have 30 bits to encode the forwardee. In the light of changed plans, I don't think it's worth the added complexity and risk of slight performance issues. I will revisit it in the future, for 4-byte-headers.

I also experimented with a different forwarding approach that would use per-region hashtables, but gave up on it for now, because performance was significantly worse than the sliding forwarding encoding.

This is in preparation of upstreaming compact object headers, and I intend to push it only once all the parts have been approved.

Testing:

  • hotspot_gc
  • tier1
  • tier2
  • tier3
  • tier4

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

Integration blocker

 ⚠️ Dependency #20603 must be integrated first

Issue

  • JDK-8305896: Alternative full GC forwarding (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20605

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 15, 2024

👋 Welcome back rkennke! 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 Aug 15, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Aug 15, 2024

@rkennke 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.

@rkennke
Copy link
Contributor Author

rkennke commented Aug 21, 2024

/label remove shenandoah
/label remove hotspot
/label add hotspot-gc

@openjdk
Copy link

openjdk bot commented Aug 21, 2024

@rkennke
The shenandoah label was successfully removed.

@openjdk
Copy link

openjdk bot commented Aug 21, 2024

@rkennke
The hotspot label was successfully removed.

@openjdk
Copy link

openjdk bot commented Aug 21, 2024

@rkennke
The hotspot-gc label was successfully added.

@rkennke rkennke changed the base branch from master to pr/20603 August 21, 2024 11:31
@rkennke rkennke marked this pull request as ready for review August 21, 2024 11:31
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 21, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 21, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Aug 22, 2024

⚠️ @rkennke 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).

@rkennke
Copy link
Contributor Author

rkennke commented Aug 22, 2024

Superseding by #20677

@rkennke rkennke closed this Aug 22, 2024
@rkennke rkennke mentioned this pull request Jul 4, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants