RFR: 8348594: Shenandoah: Do not penalize for degeneration when not the fault of triggering heuristic

William Kemper wkemper at openjdk.org
Fri Jan 24 19:03:48 UTC 2025


On Fri, 24 Jan 2025 18:18:25 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:

> Shenandoah heuristics use a penalty mechanism to cause earlier GC triggers when recent concurrent GC cycles degenerate.  Degeneration is a stop-the-world remediation that allows GC to catch up when mutator allocations fail during concurrent GC.  The fact that we needed to degenerate indicates that we were overly optimistic in delaying the trigger that starts concurrent GC.
> 
> We have observed that it is common for degenerated GC cycles to cascade upon each other.  The condition that caused an initial degenerated cycle is often not fully resolved by the end of that degenerated cycle.  For example, the application may be experiencing a phase change and the GC heuristics are not yet attuned to the new behavior.  Furthermore, a degenerated GC may exacerbate the problem condition.  During the stop-the-world pause imposed by the first degenerated GC, work continues to accumulate in the form of new client requests that are buffered in network sockets until the end of that degenerated GC.
> 
> As originally implemented, each degeneration would "pile on" additional penalties.  These penalties cause the GC frequency to continue to increase.  And the expanding CPU load of GC makes it increasingly difficult for mutator threads to catchup.  The large penalties accumulated while we are trying to resolve the problem linger long after the problem condition has been resolved.
> 
> This change does not add further to the degeneration penalties if a new degenerated cycle occurs through no fault of the triggering mechanism.  We only add the degeneration penalty if the reason we are now degenerating can be attributed to a consciously late trigger by the heuristic.

Changes requested by wkemper (Committer).

src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp line 257:

> 255:                  byte_size_in_proper_unit(available), proper_unit_for_byte_size(available),
> 256:                  byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
> 257:     _previous_trigger_declinations = _declined_trigger_count;

This stanza of code is repeated often enough to warrant a new (protected) method in `ShenandoahHeuristics`.

src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp line 227:

> 225:          "In range before adjustment: %zd", _gc_time_penalties);
> 226: 
> 227:   if ((_previous_trigger_declinations < 16) && (step > 0)) {

Could we make this `16` be a symbolic constant?

src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp line 81:

> 79:   static const uint Moving_Average_Samples = 10; // Number of samples to store in moving averages
> 80: 
> 81:   bool _start_gc_is_pending;

A description of each of these members and how they operate in this new protocol would be helpful.

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

PR Review: https://git.openjdk.org/jdk/pull/23305#pullrequestreview-2573382758
PR Review Comment: https://git.openjdk.org/jdk/pull/23305#discussion_r1929115073
PR Review Comment: https://git.openjdk.org/jdk/pull/23305#discussion_r1929116618
PR Review Comment: https://git.openjdk.org/jdk/pull/23305#discussion_r1929117150


More information about the hotspot-gc-dev mailing list