Skip to content
Permalink
Browse files
8277450: Record number of references into collection set during gc
Reviewed-by: kbarrett, iwalulya
  • Loading branch information
Thomas Schatzl committed Nov 29, 2021
1 parent 2622ab3 commit e5676f8d0b4f9e97497581e848e8b06fb7e11828
Showing 6 changed files with 19 additions and 4 deletions.
@@ -116,10 +116,12 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
_gc_par_phases[ScanHR]->create_thread_work_items("Scanned Cards:", ScanHRScannedCards);
_gc_par_phases[ScanHR]->create_thread_work_items("Scanned Blocks:", ScanHRScannedBlocks);
_gc_par_phases[ScanHR]->create_thread_work_items("Claimed Chunks:", ScanHRClaimedChunks);
_gc_par_phases[ScanHR]->create_thread_work_items("Found Roots:", ScanHRFoundRoots);

_gc_par_phases[OptScanHR]->create_thread_work_items("Scanned Cards:", ScanHRScannedCards);
_gc_par_phases[OptScanHR]->create_thread_work_items("Scanned Blocks:", ScanHRScannedBlocks);
_gc_par_phases[OptScanHR]->create_thread_work_items("Claimed Chunks:", ScanHRClaimedChunks);
_gc_par_phases[OptScanHR]->create_thread_work_items("Found Roots:", ScanHRFoundRoots);
_gc_par_phases[OptScanHR]->create_thread_work_items("Scanned Refs:", ScanHRScannedOptRefs);
_gc_par_phases[OptScanHR]->create_thread_work_items("Used Memory:", ScanHRUsedMemory);

@@ -123,6 +123,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
ScanHRScannedCards,
ScanHRScannedBlocks,
ScanHRClaimedChunks,
ScanHRFoundRoots,
ScanHRScannedOptRefs,
ScanHRUsedMemory
};
@@ -61,10 +61,12 @@ class G1ScanClosureBase : public BasicOopIterateClosure {

// Used to scan cards from the DCQS or the remembered sets during garbage collection.
class G1ScanCardClosure : public G1ScanClosureBase {
size_t& _heap_roots_found;
public:
G1ScanCardClosure(G1CollectedHeap* g1h,
G1ParScanThreadState* pss) :
G1ScanClosureBase(g1h, pss) { }
G1ParScanThreadState* pss,
size_t& heap_roots_found) :
G1ScanClosureBase(g1h, pss), _heap_roots_found(heap_roots_found) { }

template <class T> void do_oop_work(T* p);
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
@@ -180,6 +180,7 @@ inline void G1ScanCardClosure::do_oop_work(T* p) {
// Since the source is always from outside the collection set, here we implicitly know
// that this is a cross-region reference too.
prefetch_and_push(p, obj);
_heap_roots_found++;
} else if (!HeapRegion::is_in_same_region(p, obj)) {
handle_non_cset_obj_common(region_attr, p, obj);
_par_scan_state->enqueue_card_if_tracked(region_attr, p, obj);
@@ -774,6 +774,7 @@ class G1ScanHRForRegionClosure : public HeapRegionClosure {
size_t _cards_scanned;
size_t _blocks_scanned;
size_t _chunks_claimed;
size_t _heap_roots_found;

Tickspan _rem_set_root_scan_time;
Tickspan _rem_set_trim_partially_time;
@@ -785,7 +786,7 @@ class G1ScanHRForRegionClosure : public HeapRegionClosure {

HeapWord* scan_memregion(uint region_idx_for_card, MemRegion mr) {
HeapRegion* const card_region = _g1h->region_at(region_idx_for_card);
G1ScanCardClosure card_cl(_g1h, _pss);
G1ScanCardClosure card_cl(_g1h, _pss, _heap_roots_found);

HeapWord* const scanned_to = card_region->oops_on_memregion_seq_iterate_careful<true>(mr, &card_cl);
assert(scanned_to != NULL, "Should be able to scan range");
@@ -880,6 +881,7 @@ class G1ScanHRForRegionClosure : public HeapRegionClosure {
_cards_scanned(0),
_blocks_scanned(0),
_chunks_claimed(0),
_heap_roots_found(0),
_rem_set_root_scan_time(),
_rem_set_trim_partially_time(),
_scanned_to(NULL),
@@ -906,6 +908,7 @@ class G1ScanHRForRegionClosure : public HeapRegionClosure {
size_t cards_scanned() const { return _cards_scanned; }
size_t blocks_scanned() const { return _blocks_scanned; }
size_t chunks_claimed() const { return _chunks_claimed; }
size_t heap_roots_found() const { return _heap_roots_found; }
};

void G1RemSet::scan_heap_roots(G1ParScanThreadState* pss,
@@ -924,6 +927,7 @@ void G1RemSet::scan_heap_roots(G1ParScanThreadState* pss,
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.cards_scanned(), G1GCPhaseTimes::ScanHRScannedCards);
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.blocks_scanned(), G1GCPhaseTimes::ScanHRScannedBlocks);
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.chunks_claimed(), G1GCPhaseTimes::ScanHRClaimedChunks);
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.heap_roots_found(), G1GCPhaseTimes::ScanHRFoundRoots);
}

// Heap region closure to be applied to all regions in the current collection set
@@ -937,6 +941,7 @@ class G1ScanCollectionSetRegionClosure : public HeapRegionClosure {

uint _worker_id;

size_t _opt_roots_scanned;
size_t _opt_refs_scanned;
size_t _opt_refs_memory_used;

@@ -951,7 +956,7 @@ class G1ScanCollectionSetRegionClosure : public HeapRegionClosure {

G1OopStarChunkedList* opt_rem_set_list = _pss->oops_into_optional_region(r);

G1ScanCardClosure scan_cl(G1CollectedHeap::heap(), _pss);
G1ScanCardClosure scan_cl(G1CollectedHeap::heap(), _pss, _opt_roots_scanned);
G1ScanRSForOptionalClosure cl(G1CollectedHeap::heap(), &scan_cl);
_opt_refs_scanned += opt_rem_set_list->oops_do(&cl, _pss->closures()->strong_oops());
_opt_refs_memory_used += opt_rem_set_list->used_memory();
@@ -970,6 +975,7 @@ class G1ScanCollectionSetRegionClosure : public HeapRegionClosure {
_scan_phase(scan_phase),
_code_roots_phase(code_roots_phase),
_worker_id(worker_id),
_opt_roots_scanned(0),
_opt_refs_scanned(0),
_opt_refs_memory_used(0),
_strong_code_root_scan_time(),
@@ -1006,6 +1012,7 @@ class G1ScanCollectionSetRegionClosure : public HeapRegionClosure {
Tickspan rem_set_opt_root_scan_time() const { return _rem_set_opt_root_scan_time; }
Tickspan rem_set_opt_trim_partially_time() const { return _rem_set_opt_trim_partially_time; }

size_t opt_roots_scanned() const { return _opt_roots_scanned; }
size_t opt_refs_scanned() const { return _opt_refs_scanned; }
size_t opt_refs_memory_used() const { return _opt_refs_memory_used; }
};
@@ -1028,6 +1035,7 @@ void G1RemSet::scan_collection_set_regions(G1ParScanThreadState* pss,

// At this time we record some metrics only for the evacuations after the initial one.
if (scan_phase == G1GCPhaseTimes::OptScanHR) {
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.opt_roots_scanned(), G1GCPhaseTimes::ScanHRFoundRoots);
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.opt_refs_scanned(), G1GCPhaseTimes::ScanHRScannedOptRefs);
p->record_or_add_thread_work_item(scan_phase, worker_id, cl.opt_refs_memory_used(), G1GCPhaseTimes::ScanHRUsedMemory);
}
@@ -142,6 +142,7 @@ public boolean isAvailable() {
new LogMessageWithLevel("Scanned Cards", Level.DEBUG),
new LogMessageWithLevel("Scanned Blocks", Level.DEBUG),
new LogMessageWithLevel("Claimed Chunks", Level.DEBUG),
new LogMessageWithLevel("Found Roots", Level.DEBUG),
// Code Roots Scan
new LogMessageWithLevel("Code Root Scan", Level.DEBUG),
// Object Copy

1 comment on commit e5676f8

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on e5676f8 Nov 29, 2021

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.