Skip to content

Commit

Permalink
8316297: GenShen: Degenerated GCs fail to make progress
Browse files Browse the repository at this point in the history
Reviewed-by: wkemper
  • Loading branch information
kdnilsen committed Sep 15, 2023
1 parent ba88eb1 commit 88365d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,12 @@ void ShenandoahGeneration::compute_evacuation_budgets(ShenandoahHeap* heap, bool
size_t maximum_young_evacuation_reserve = (young_generation->max_capacity() * ShenandoahEvacReserve) / 100;
size_t young_evacuation_reserve = maximum_young_evacuation_reserve;
size_t excess_young;
if (young_generation->available() > young_evacuation_reserve) {
excess_young = young_generation->available() - young_evacuation_reserve;

size_t total_young_available = young_generation->available_with_reserve();
if (total_young_available > young_evacuation_reserve) {
excess_young = total_young_available - young_evacuation_reserve;
} else {
young_evacuation_reserve = young_generation->available();
young_evacuation_reserve = total_young_available;
excess_young = 0;
}
size_t unaffiliated_young = young_generation->free_unaffiliated_regions() * region_size_bytes;
Expand All @@ -275,6 +277,8 @@ void ShenandoahGeneration::compute_evacuation_budgets(ShenandoahHeap* heap, bool
// already been set aside for its promotion and evacuation needs at the end of previous GC. No need to
// hold back memory for allocation runway.

// TODO: excess_young is unused. Did we want to add it old_promo_reserve and/or old_evacuation_reserve?

ShenandoahOldHeuristics* old_heuristics = heap->old_heuristics();

// maximum_old_evacuation_reserve is an upper bound on memory evacuated from old and evacuated to old (promoted).
Expand Down Expand Up @@ -406,7 +410,8 @@ void ShenandoahGeneration::adjust_evacuation_budgets(ShenandoahHeap* heap, Shena
size_t young_evacuated = collection_set->get_young_bytes_reserved_for_evacuation();
size_t young_evacuated_reserve_used = (size_t) (ShenandoahEvacWaste * young_evacuated);

assert(young_evacuated_reserve_used <= young_generation->available(), "Cannot evacuate more than is available in young");
size_t total_young_available = young_generation->available_with_reserve();
assert(young_evacuated_reserve_used <= total_young_available, "Cannot evacuate more than is available in young");
heap->set_young_evac_reserve(young_evacuated_reserve_used);

size_t old_available = old_generation->available();
Expand Down Expand Up @@ -955,6 +960,11 @@ size_t ShenandoahGeneration::available() const {
return available(max_capacity());
}

// For ShenandoahYoungGeneration, Include the young available that may have been reserved for the Collector.
size_t ShenandoahGeneration::available_with_reserve() const {
return available(max_capacity());
}

size_t ShenandoahGeneration::soft_available() const {
return available(soft_max_capacity());
}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
virtual size_t free_unaffiliated_regions() const;
size_t used() const override { return _used; }
size_t available() const override;
size_t available_with_reserve() const;

// Returns the memory available based on the _soft_ max heap capacity (soft_max_heap - used).
// The soft max heap size may be adjusted lower than the max heap size to cause the trigger
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class ShenandoahYoungGeneration : public ShenandoahGeneration {
}

size_t available() const override;

// Do not override available_with_reserve() because that needs to see memory reserved for Collector

size_t soft_available() const override;
};

Expand Down

0 comments on commit 88365d1

Please sign in to comment.