Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
/ jdk20 Public archive

Commit

Permalink
8298968: G1: Incorrect merged remset stats
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, kbarrett
  • Loading branch information
albertnetymk committed Dec 20, 2022
1 parent 3dd2cfa commit 65fc058
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/hotspot/share/gc/g1/g1RemSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -1347,24 +1347,22 @@ class G1MergeHeapRootsTask : public WorkerTask {

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);
Expand Down

1 comment on commit 65fc058

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.