Skip to content

Commit b4ba74e

Browse files
Hamlin Limashoubing
Hamlin Li
andcommitted
8264987: G1: Fill BOTs for Survivor-turned-to-Old regions in full gc
Co-authored-by: Shoubing Ma <mashoubing1@huawei.com> Reviewed-by: tschatzl, sjohanss
1 parent fc89fe6 commit b4ba74e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,16 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion*
6363
} else {
6464
assert(MarkSweepDeadRatio > 0,
6565
"only skip compaction for other regions when MarkSweepDeadRatio > 0");
66-
6766
// Force the high live ratio region as compacting to skip these regions in the
6867
// later compaction step.
6968
force_not_compacted = true;
69+
if (hr->is_young()) {
70+
// G1 updates the BOT for old region contents incrementally, but young regions
71+
// lack BOT information for performance reasons.
72+
// Recreate BOT information of high live ratio young regions here to keep expected
73+
// performance during scanning their card tables in the collection pauses later.
74+
update_bot(hr);
75+
}
7076
log_debug(gc, phases)("Phase 2: skip compaction region index: %u, live words: " SIZE_FORMAT,
7177
hr->hrm_index(), _collector->live_words(hr->hrm_index()));
7278
}
@@ -157,6 +163,22 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::should_compact(HeapRegion*
157163
return live_words <= live_words_threshold;
158164
}
159165

166+
void G1FullGCPrepareTask::G1CalculatePointersClosure::update_bot(HeapRegion* hr) {
167+
HeapWord* const limit = hr->top();
168+
HeapWord* next_addr = hr->bottom();
169+
HeapWord* threshold = hr->initialize_threshold();
170+
HeapWord* prev_addr;
171+
while (next_addr < limit) {
172+
prev_addr = next_addr;
173+
next_addr = _bitmap->get_next_marked_addr(next_addr + 1, limit);
174+
175+
if (next_addr > threshold) {
176+
threshold = hr->cross_threshold(prev_addr, next_addr);
177+
}
178+
}
179+
assert(next_addr == limit, "Should stop the scan at the limit.");
180+
}
181+
160182
void G1FullGCPrepareTask::G1CalculatePointersClosure::reset_region_metadata(HeapRegion* hr) {
161183
hr->rem_set()->clear();
162184
hr->clear_cardtable();

src/hotspot/share/gc/g1/g1FullGCPrepareTask.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class G1FullGCPrepareTask : public G1FullGCTask {
6363
void prepare_for_compaction_work(G1FullGCCompactionPoint* cp, HeapRegion* hr);
6464
void free_humongous_region(HeapRegion* hr);
6565
void free_open_archive_region(HeapRegion* hr);
66+
void update_bot(HeapRegion* hr);
6667

6768
void reset_region_metadata(HeapRegion* hr);
6869

0 commit comments

Comments
 (0)