8288947: G1: Consolidate per-region is-humongous query in G1CollectedHeap

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2022-07-04 15:18:24 +00:00
parent b5d965656d
commit bad9ffe471
5 changed files with 12 additions and 45 deletions

View File

@ -1452,7 +1452,6 @@ G1CollectedHeap::G1CollectedHeap() :
_survivor_evac_stats("Young", YoungPLABSize, PLABWeight),
_old_evac_stats("Old", OldPLABSize, PLABWeight),
_monitoring_support(nullptr),
_humongous_reclaim_candidates(),
_num_humongous_objects(0),
_num_humongous_reclaim_candidates(0),
_hr_printer(),
@ -1684,7 +1683,6 @@ jint G1CollectedHeap::initialize() {
size_t granularity = HeapRegion::GrainBytes;
_region_attr.initialize(reserved(), granularity);
_humongous_reclaim_candidates.initialize(reserved(), granularity);
}
_workers = new WorkerThreads("GC Thread", ParallelGCThreads);

View File

@ -229,26 +229,6 @@ private:
// Helper for monitoring and management support.
G1MonitoringSupport* _monitoring_support;
// Records whether the region at the given index is (still) a
// candidate for eager reclaim. Only valid for humongous start
// regions; other regions have unspecified values. Humongous start
// regions are initialized at start of collection pause, with
// candidates removed from the set as they are found reachable from
// roots or the young generation.
class HumongousReclaimCandidates : public G1BiasedMappedArray<bool> {
protected:
bool default_value() const override { return false; }
public:
void clear() { G1BiasedMappedArray<bool>::clear(); }
void set_candidate(uint region, bool value) {
set_by_index(region, value);
}
bool is_candidate(uint region) {
return get_by_index(region);
}
};
HumongousReclaimCandidates _humongous_reclaim_candidates;
uint _num_humongous_objects; // Current amount of (all) humongous objects found in the heap.
uint _num_humongous_reclaim_candidates; // Number of humongous object eager reclaim candidates.
public:
@ -590,9 +570,6 @@ public:
// Does the given region fulfill remembered set based eager reclaim candidate requirements?
bool is_potential_eager_reclaim_candidate(HeapRegion* r) const;
// Modify the reclaim candidate set and test for presence.
// These are only valid for starts_humongous regions.
inline void set_humongous_reclaim_candidate(uint region, bool value);
inline bool is_humongous_reclaim_candidate(uint region);
// Remove from the reclaim candidate set. Also remove from the

View File

@ -239,30 +239,20 @@ inline bool G1CollectedHeap::is_obj_dead_full(const oop obj) const {
return is_obj_dead_full(obj, heap_region_containing(obj));
}
inline void G1CollectedHeap::set_humongous_reclaim_candidate(uint region, bool value) {
assert(_hrm.at(region)->is_starts_humongous(), "Must start a humongous object");
_humongous_reclaim_candidates.set_candidate(region, value);
}
inline bool G1CollectedHeap::is_humongous_reclaim_candidate(uint region) {
assert(_hrm.at(region)->is_starts_humongous(), "Must start a humongous object");
return _humongous_reclaim_candidates.is_candidate(region);
return _region_attr.is_humongous(region);
}
inline void G1CollectedHeap::set_humongous_is_live(oop obj) {
uint region = addr_to_region(cast_from_oop<HeapWord*>(obj));
// Clear the flag in the humongous_reclaim_candidates table. Also
// reset the entry in the region attribute table so that subsequent references
// to the same humongous object do not go into the slow path again.
// This is racy, as multiple threads may at the same time enter here, but this
// is benign.
// During collection we only ever clear the "candidate" flag, and only ever clear the
// entry in the in_cset_fast_table.
// We only ever evaluate the contents of these tables (in the VM thread) after
// having synchronized the worker threads with the VM thread, or in the same
// thread (i.e. within the VM thread).
if (is_humongous_reclaim_candidate(region)) {
set_humongous_reclaim_candidate(region, false);
// Reset the entry in the region attribute table so that subsequent
// references to the same humongous object do not go into the slow path
// again. This is racy, as multiple threads may at the same time enter here,
// but this is benign because the transition is unidirectional, from
// humongous-candidate to not, and the write, in evacuation, is
// separated from the read, in post-evacuation.
if (_region_attr.is_humongous(region)) {
_region_attr.clear_humongous(region);
}
}

View File

@ -142,6 +142,10 @@ class G1HeapRegionAttrBiasedMappedArray : public G1BiasedMappedArray<G1HeapRegio
get_ref_by_index(index)->clear_humongous();
}
bool is_humongous(uintptr_t index) {
return get_ref_by_index(index)->is_humongous();
}
void set_remset_is_tracked(uintptr_t index, bool remset_is_tracked) {
get_ref_by_index(index)->set_remset_is_tracked(remset_is_tracked);
}

View File

@ -383,12 +383,10 @@ class G1PrepareEvacuationTask : public WorkerTask {
uint index = hr->hrm_index();
if (humongous_region_is_candidate(hr)) {
_g1h->set_humongous_reclaim_candidate(index, true);
_g1h->register_humongous_region_with_region_attr(index);
_worker_humongous_candidates++;
// We will later handle the remembered sets of these regions.
} else {
_g1h->set_humongous_reclaim_candidate(index, false);
_g1h->register_region_with_region_attr(hr);
}
log_debug(gc, humongous)("Humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT ") remset " SIZE_FORMAT " code roots " SIZE_FORMAT " marked %d reclaim candidate %d type array %d",