RFR: 8373714: Shenandoah: Register heuristic penalties following a degenerated GC

Kelvin Nilsen kdnilsen at openjdk.org
Tue Dec 16 15:12:04 UTC 2025


On Tue, 16 Dec 2025 14:51:08 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp line 314:
>> 
>>> 312:   ShenandoahCollectorPolicy* policy = heap->shenandoah_policy();
>>> 313:   policy->record_degenerated(_generation->is_young(), _abbreviated, progress);
>>> 314:   if (progress || (heap->mode()->is_generational() && !policy->generational_should_upgrade_degenerated_gc())) {
>> 
>> I'm not sure why we want to change the logic here. Previously, if there was no progress, and we were in generational mode and the policy said _not_ to upgrade to a full GC, nothing would happen here. Now we are treating that case the same as if there were progress, when there might not have been. `heap->notifiy_gc_progress()`  resets the `no progress counter`, which has implications for how many times Shenandoah will retry allocations. We need to be careful to avoid an allocation loop that just runs degenerated cycles forever (brownout).
>
> This "avoids" a third arm of the if-then-else (rather than if-then-else-if-then-else-if).  In the case that we do upgrade to full gc, we'll experience a full-gc penalty.  In the case that we do not upgrade to full-gc following failed degen progress, we need "somehow" to incur the degen penalty.  This is how I proposed to do that.

I see this composition of the code results in unclear intentions.  Before the if test, we tell policy that we had a degenerated gc with "no progress".  But inside the if-body, we tell the generation heuristics that we had a successful degenerated cycle.  So I should restructure this code.

What I was trying to fix is that in the previous code, we never imposed a Degen Penalty if we had no degen progress and we did not upgrade to full GC.

Thanks for this catch.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28834#discussion_r2623680165


More information about the hotspot-gc-dev mailing list