Skip to content

Conversation

@rgithubli
Copy link
Contributor

@rgithubli rgithubli commented Oct 24, 2025

Add card barriers to passive mode to test out the price of card barriers.

How this change is implemented is to instantiate the old region in passive mode - old region owns the card table so this would minimize the code change with a bit price of native memory. It does sound weird to have old gen in passive mode, but since passive mode is a just diagnostic mode, we'll go with it for the cleanliness of the change.


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-8369013: Shenandoah: passive mode should support enabling ShenandoahCardBarrier (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27966

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 24, 2025

👋 Welcome back rgithubli! 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 Oct 24, 2025

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

8369013: Shenandoah: passive mode should support enabling ShenandoahCardBarrier

Reviewed-by: wkemper

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 79 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@earthling-amzn) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

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

Copy link
Contributor

@earthling-amzn earthling-amzn left a comment

Choose a reason for hiding this comment

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

This turned out to be simpler than expected. Nice work. I suggest some small changes.

// it means we're under passive mode and we have to initialize old gen
// for the purpose of having card table.
if (ShenandoahCardBarrier && !(mode()->is_generational())) {
_generation_sizer.heap_size_changed(max_capacity());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could simplify here by not using the _generation_sizer. It should be fine to pass max_capacity() instead of max_capacity_old here.

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 that'd be simpler. Updating. Thanks.

}

ShenandoahOldGeneration* old_generation() const {
assert(mode()->is_generational(), "Old generation requires generational mode");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assert that ShenandoahCardBarrier is on instead of removing this assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

ConcurrentGCTimer* _gc_timer;
// For exporting to SA
int _log_min_obj_alignment_in_bytes;
ShenandoahGenerationSizer _generation_sizer;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this here.

void initialize_heuristics() override;

static ShenandoahGenerationalHeap* heap() {
shenandoah_assert_generational();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put these assertions back? I don't see any code in the PR that would invalidate these assertions. I also don't see any changes that would instantiate the generational heap for non generational mode, so if there is code trying to use the generational heap, its behavior will be undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would crash at here with the assertion: code. Provided some of the stacktrace below. It's mostly because we enabled card barrier flag and the code just fell through and assumes it's generational.

Would it be more appropriate to change this line to be ShenandoahHeap* heap = ShenandoahHeap::heap();?

Stack: [0x00007f1082bd2000,0x00007f1082cd2000],  sp=0x00007f1082cce370,  free space=1008k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x13e0e90]  NativeStackPrinter::print_stack(outputStream*, char*, int, unsigned char*&, bool
, int)+0x70  (shenandoahGenerationalHeap.hpp:47)
V  [libjvm.so+0x18fd2e9]  VMError::report(outputStream*, bool)+0x1bff  (vmError.cpp:979)
V  [libjvm.so+0x1900d01]  VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, 
unsigned char*, void const*, void const*, char const*, int, unsigned long)+0x8b1  (vmError.cpp:1887)
V  [libjvm.so+0xacf5ca]  report_vm_status_error(char const*, int, char const*, int, char const*)+0x0  (deb
ug.cpp:196)
V  [libjvm.so+0xacf33b]  print_error_for_unit_test(char const*, char const*, __va_list_tag*)+0x0  (debug.c
pp:149)
V  [libjvm.so+0x15bbec1]  ShenandoahAsserts::assert_generational(char const*, int)+0x8b  (shenandoahAssert
s.cpp:532)
V  [libjvm.so+0x15be196]  ShenandoahGenerationalHeap::heap()+0x19  (shenandoahGenerationalHeap.hpp:47)
V  [libjvm.so+0x16993bc]  void card_mark_barrier<narrowOop>(narrowOop*, oopDesc*)+0x73  (shenandoahReferenceProcessor.cpp:65)
V  [libjvm.so+0x169a2ac]  bool ShenandoahReferenceProcessor::discover<narrowOop>(oopDesc*, ReferenceType, unsigned int)+0x1da  (shenandoahReferenceProcessor.cpp:409)
V  [libjvm.so+0x1698a5d]  ShenandoahReferenceProcessor::discover_reference(oopDesc*, ReferenceType)+0xed  (shenandoahReferenceProcessor.cpp:433)
V  [libjvm.so+0x1684aeb]  bool InstanceRefKlass::try_discover<narrowOop, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0> >(oopDesc*, ReferenceType, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>*)+0x77  (instanceRefKlass.inline.hpp:74)
V  [libjvm.so+0x1682bfc]  void InstanceRefKlass::oop_oop_iterate_discovery<narrowOop, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>, AlwaysContains>(oopDesc*, ReferenceType, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>*, AlwaysContains&)+0x2c  (instanceRefKlass.inline.hpp:84)
V  [libjvm.so+0x1680acc]  void InstanceRefKlass::oop_oop_iterate_ref_processing<narrowOop, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>, AlwaysContains>(oopDesc*, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>*, AlwaysContains&)+0x80  (instanceRefKlass.inline.hpp:111)
V  [libjvm.so+0x167ec2e]  void InstanceRefKlass::oop_oop_iterate_ref_processing<narrowOop, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0> >(oopDesc*, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>*)+0x2c  (instanceRefKlass.inline.hpp:134)
V  [libjvm.so+0x167ba88]  void InstanceRefKlass::oop_oop_iterate<narrowOop, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0> >(oopDesc*, ShenandoahMarkRefsClosure<(ShenandoahGenerationType)0>*)+0x16c  (instanceRefKlass.inline.hpp:154)

@rgithubli rgithubli marked this pull request as ready for review October 28, 2025 17:29
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 28, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 28, 2025

Webrevs

Copy link
Contributor

@earthling-amzn earthling-amzn 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. I think we should clear the card table for each degenerated cycle. Thank you for adding the test!

}

// passive mode with ShenandoahCardBarrier turned on, clean the write table without swapping the tables
if (ShenandoahCardBarrier && !heap->mode()->is_generational()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, the passive mode will only initiate a degenerated cycle. It will run a full GC only if the degenerated cycle cannot evacuate or it doesn't make "good progress". Could we move this behavior into shDegeneratedGC or somewhere in shPassiveHeuristic? Cleaning the card table on every GC would be more aligned with the concurrent mode behavior.

Copy link
Contributor

@earthling-amzn earthling-amzn 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. Thank you!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 29, 2025
@rgithubli
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 29, 2025
@openjdk
Copy link

openjdk bot commented Oct 29, 2025

@rgithubli
Your change (at version e6fdbc6) is now ready to be sponsored by a Committer.

@pengxiaolong
Copy link

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 29, 2025

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 29, 2025
@openjdk openjdk bot closed this Oct 29, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Oct 29, 2025
@openjdk
Copy link

openjdk bot commented Oct 29, 2025

@pengxiaolong @rgithubli Pushed as commit f3dfdfa.

💡 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

Development

Successfully merging this pull request may close these issues.

3 participants