Skip to content

Commit ec059c0

Browse files
committed
8365880: Shenandoah: Unify memory usage accounting in ShenandoahFreeSet
Reviewed-by: wkemper
1 parent 1781b18 commit ec059c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2455
-1351
lines changed

src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti
8888
size_t min_garbage = (free_target > actual_free) ? (free_target - actual_free) : 0;
8989

9090
log_info(gc, ergo)("Adaptive CSet Selection for GLOBAL. Max Young Evacuation: %zu"
91-
"%s, Max Old Evacuation: %zu%s, Actual Free: %zu%s.",
91+
"%s, Max Old Evacuation: %zu%s, Max Either Evacuation: %zu%s, Actual Free: %zu%s.",
9292
byte_size_in_proper_unit(max_young_cset), proper_unit_for_byte_size(max_young_cset),
9393
byte_size_in_proper_unit(max_old_cset), proper_unit_for_byte_size(max_old_cset),
94+
byte_size_in_proper_unit(unaffiliated_young_memory), proper_unit_for_byte_size(unaffiliated_young_memory),
9495
byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free));
9596

9697
for (size_t idx = 0; idx < size; idx++) {
@@ -133,9 +134,8 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti
133134
cset->add_region(r);
134135
}
135136
}
136-
137137
if (regions_transferred_to_old > 0) {
138-
heap->generation_sizer()->force_transfer_to_old(regions_transferred_to_old);
138+
assert(young_evac_reserve > regions_transferred_to_old * region_size_bytes, "young reserve cannot be negative");
139139
heap->young_generation()->set_evacuation_reserve(young_evac_reserve - regions_transferred_to_old * region_size_bytes);
140140
heap->old_generation()->set_evacuation_reserve(old_evac_reserve + regions_transferred_to_old * region_size_bytes);
141141
}

src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,12 @@ void ShenandoahOldHeuristics::set_trigger_if_old_is_fragmented(size_t first_old_
606606
}
607607

608608
void ShenandoahOldHeuristics::set_trigger_if_old_is_overgrown() {
609-
size_t old_used = _old_generation->used() + _old_generation->get_humongous_waste();
609+
// used() includes humongous waste
610+
size_t old_used = _old_generation->used();
610611
size_t trigger_threshold = _old_generation->usage_trigger_threshold();
611612
// Detects unsigned arithmetic underflow
612613
assert(old_used <= _heap->capacity(),
613-
"Old used (%zu, %zu) must not be more than heap capacity (%zu)",
614-
_old_generation->used(), _old_generation->get_humongous_waste(), _heap->capacity());
614+
"Old used (%zu) must not be more than heap capacity (%zu)", _old_generation->used(), _heap->capacity());
615615
if (old_used > trigger_threshold) {
616616
_growth_trigger = true;
617617
}
@@ -683,7 +683,8 @@ bool ShenandoahOldHeuristics::should_start_gc() {
683683
if (_growth_trigger) {
684684
// Growth may be falsely triggered during mixed evacuations, before the mixed-evacuation candidates have been
685685
// evacuated. Before acting on a false trigger, we check to confirm the trigger condition is still satisfied.
686-
const size_t current_usage = _old_generation->used() + _old_generation->get_humongous_waste();
686+
// _old_generation->used() includes humongous waste.
687+
const size_t current_usage = _old_generation->used();
687688
const size_t trigger_threshold = _old_generation->usage_trigger_threshold();
688689
const size_t heap_size = heap->capacity();
689690
const size_t ignore_threshold = (ShenandoahIgnoreOldGrowthBelowPercentage * heap_size) / 100;

src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp

Lines changed: 1515 additions & 298 deletions
Large diffs are not rendered by default.

src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp

Lines changed: 380 additions & 69 deletions
Large diffs are not rendered by default.

src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ void ShenandoahFullGC::do_it(GCCause::Cause gc_cause) {
237237
worker_slices[i] = new ShenandoahHeapRegionSet();
238238
}
239239

240-
ShenandoahGenerationalHeap::TransferResult result;
241240
{
242241
// The rest of code performs region moves, where region status is undefined
243242
// until all phases run together.
@@ -251,14 +250,7 @@ void ShenandoahFullGC::do_it(GCCause::Cause gc_cause) {
251250

252251
phase4_compact_objects(worker_slices);
253252

254-
result = phase5_epilog();
255-
}
256-
if (heap->mode()->is_generational()) {
257-
LogTarget(Info, gc, ergo) lt;
258-
if (lt.is_enabled()) {
259-
LogStream ls(lt);
260-
result.print_on("Full GC", &ls);
261-
}
253+
phase5_epilog();
262254
}
263255

264256
// Resize metaspace
@@ -984,23 +976,6 @@ class ShenandoahPostCompactClosure : public ShenandoahHeapRegionClosure {
984976
r->set_live_data(live);
985977
r->reset_alloc_metadata();
986978
}
987-
988-
void update_generation_usage() {
989-
if (_is_generational) {
990-
_heap->old_generation()->establish_usage(_old_regions, _old_usage, _old_humongous_waste);
991-
_heap->young_generation()->establish_usage(_young_regions, _young_usage, _young_humongous_waste);
992-
} else {
993-
assert(_old_regions == 0, "Old regions only expected in generational mode");
994-
assert(_old_usage == 0, "Old usage only expected in generational mode");
995-
assert(_old_humongous_waste == 0, "Old humongous waste only expected in generational mode");
996-
}
997-
998-
// In generational mode, global usage should be the sum of young and old. This is also true
999-
// for non-generational modes except that there are no old regions.
1000-
_heap->global_generation()->establish_usage(_old_regions + _young_regions,
1001-
_old_usage + _young_usage,
1002-
_old_humongous_waste + _young_humongous_waste);
1003-
}
1004979
};
1005980

1006981
void ShenandoahFullGC::compact_humongous_objects() {
@@ -1120,10 +1095,9 @@ void ShenandoahFullGC::phase4_compact_objects(ShenandoahHeapRegionSet** worker_s
11201095
}
11211096
}
11221097

1123-
ShenandoahGenerationalHeap::TransferResult ShenandoahFullGC::phase5_epilog() {
1098+
void ShenandoahFullGC::phase5_epilog() {
11241099
GCTraceTime(Info, gc, phases) time("Phase 5: Full GC epilog", _gc_timer);
11251100
ShenandoahHeap* heap = ShenandoahHeap::heap();
1126-
ShenandoahGenerationalHeap::TransferResult result;
11271101

11281102
// Reset complete bitmap. We're about to reset the complete-top-at-mark-start pointer
11291103
// and must ensure the bitmap is in sync.
@@ -1138,12 +1112,6 @@ ShenandoahGenerationalHeap::TransferResult ShenandoahFullGC::phase5_epilog() {
11381112
ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_copy_objects_rebuild);
11391113
ShenandoahPostCompactClosure post_compact;
11401114
heap->heap_region_iterate(&post_compact);
1141-
post_compact.update_generation_usage();
1142-
1143-
if (heap->mode()->is_generational()) {
1144-
ShenandoahGenerationalFullGC::balance_generations_after_gc(heap);
1145-
}
1146-
11471115
heap->collection_set()->clear();
11481116
size_t young_cset_regions, old_cset_regions;
11491117
size_t first_old, last_old, num_old;
@@ -1166,11 +1134,7 @@ ShenandoahGenerationalHeap::TransferResult ShenandoahFullGC::phase5_epilog() {
11661134
_preserved_marks->restore(heap->workers());
11671135
_preserved_marks->reclaim();
11681136

1169-
// We defer generation resizing actions until after cset regions have been recycled. We do this even following an
1170-
// abbreviated cycle.
11711137
if (heap->mode()->is_generational()) {
1172-
result = ShenandoahGenerationalFullGC::balance_generations_after_rebuilding_free_set();
11731138
ShenandoahGenerationalFullGC::rebuild_remembered_set(heap);
11741139
}
1175-
return result;
11761140
}

src/hotspot/share/gc/shenandoah/shenandoahFullGC.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class ShenandoahFullGC : public ShenandoahGC {
8282
void phase2_calculate_target_addresses(ShenandoahHeapRegionSet** worker_slices);
8383
void phase3_update_references();
8484
void phase4_compact_objects(ShenandoahHeapRegionSet** worker_slices);
85-
ShenandoahGenerationalHeap::TransferResult phase5_epilog();
86-
85+
void phase5_epilog();
8786
void distribute_slices(ShenandoahHeapRegionSet** worker_slices);
8887
void calculate_target_humongous_objects();
8988
void compact_humongous_objects();

0 commit comments

Comments
 (0)