8298968: G1: Incorrect merged remset stats

Reviewed-by: tschatzl, kbarrett
This commit is contained in:
Albert Mingkun Yang 2022-12-20 12:43:53 +00:00
parent 3dd2cfabdc
commit 65fc05884b

View File

@ -1031,7 +1031,7 @@ class G1MergeHeapRootsTask : public WorkerTask {
G1MergeHeapRootsPrefetchCache<G1CardTable::CardValue>(G1CardTable::dirty_card_val()),
_merge_card_cl(merge_card_cl) { }
~G1MergeCardSetCache() {
void flush() {
for (uint i = 0; i < CacheSize; i++) {
_merge_card_cl->mark_card(push(&_dummy_card));
}
@ -1120,7 +1120,10 @@ class G1MergeHeapRootsTask : public WorkerTask {
return false;
}
G1MergeCardSetStats stats() const { return _stats; }
G1MergeCardSetStats stats() {
_merge_card_set_cache.flush();
return _stats;
}
};
// Closure to make sure that the marking bitmap is clear for any old region in
@ -1187,11 +1190,10 @@ class G1MergeHeapRootsTask : public WorkerTask {
// Visitor for the remembered sets of humongous candidate regions to merge their
// remembered set into the card table.
class G1FlushHumongousCandidateRemSets : public HeapRegionIndexClosure {
G1RemSetScanState* _scan_state;
G1MergeCardSetStats _merge_stats;
G1MergeCardSetClosure _cl;
public:
G1FlushHumongousCandidateRemSets(G1RemSetScanState* scan_state) : _scan_state(scan_state), _merge_stats() { }
G1FlushHumongousCandidateRemSets(G1RemSetScanState* scan_state) : _cl(scan_state) { }
bool do_heap_region_index(uint region_index) override {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
@ -1208,12 +1210,8 @@ class G1MergeHeapRootsTask : public WorkerTask {
guarantee(r->rem_set()->occupancy_less_or_equal_than(G1EagerReclaimRemSetThreshold),
"Found a not-small remembered set here. This is inconsistent with previous assumptions.");
G1MergeCardSetStats stats;
{
G1MergeCardSetClosure cl(_scan_state);
cl.merge_card_set_for_region(r);
stats = cl.stats();
}
_cl.merge_card_set_for_region(r);
// We should only clear the card based remembered set here as we will not
// implicitly rebuild anything else during eager reclaim. Note that at the moment
@ -1233,7 +1231,9 @@ class G1MergeHeapRootsTask : public WorkerTask {
return false;
}
size_t merged(uint i) const { return _merge_stats.merged(i); }
G1MergeCardSetStats stats() {
return _cl.stats();
}
};
// Visitor for the log buffer entries to merge them into the card table.
@ -1347,24 +1347,22 @@ public:
G1FlushHumongousCandidateRemSets cl(_scan_state);
g1h->heap_region_iterate(&cl);
G1MergeCardSetStats stats = cl.stats();
for (uint i = 0; i < G1GCPhaseTimes::MergeRSContainersSentinel; i++) {
p->record_or_add_thread_work_item(merge_remset_phase, worker_id, cl.merged(i), i);
p->record_or_add_thread_work_item(merge_remset_phase, worker_id, stats.merged(i), i);
}
}
}
{
// 2. collection set
G1MergeCardSetStats stats;
{
G1MergeCardSetClosure merge(_scan_state);
G1ClearBitmapClosure clear(g1h);
G1CombinedClosure combined(&merge, &clear);
G1MergeCardSetClosure merge(_scan_state);
G1ClearBitmapClosure clear(g1h);
G1CombinedClosure combined(&merge, &clear);
g1h->collection_set_iterate_increment_from(&combined, nullptr, worker_id);
stats = merge.stats();
}
g1h->collection_set_iterate_increment_from(&combined, nullptr, worker_id);
G1MergeCardSetStats stats = merge.stats();
for (uint i = 0; i < G1GCPhaseTimes::MergeRSContainersSentinel; i++) {
p->record_or_add_thread_work_item(merge_remset_phase, worker_id, stats.merged(i), i);