Skip to content

Commit bad9ffe

Browse files
committed
8288947: G1: Consolidate per-region is-humongous query in G1CollectedHeap
Reviewed-by: tschatzl, iwalulya
1 parent b5d9656 commit bad9ffe

File tree

5 files changed

+12
-45
lines changed

5 files changed

+12
-45
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,6 @@ G1CollectedHeap::G1CollectedHeap() :
14521452
_survivor_evac_stats("Young", YoungPLABSize, PLABWeight),
14531453
_old_evac_stats("Old", OldPLABSize, PLABWeight),
14541454
_monitoring_support(nullptr),
1455-
_humongous_reclaim_candidates(),
14561455
_num_humongous_objects(0),
14571456
_num_humongous_reclaim_candidates(0),
14581457
_hr_printer(),
@@ -1684,7 +1683,6 @@ jint G1CollectedHeap::initialize() {
16841683
size_t granularity = HeapRegion::GrainBytes;
16851684

16861685
_region_attr.initialize(reserved(), granularity);
1687-
_humongous_reclaim_candidates.initialize(reserved(), granularity);
16881686
}
16891687

16901688
_workers = new WorkerThreads("GC Thread", ParallelGCThreads);

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -229,26 +229,6 @@ class G1CollectedHeap : public CollectedHeap {
229229
// Helper for monitoring and management support.
230230
G1MonitoringSupport* _monitoring_support;
231231

232-
// Records whether the region at the given index is (still) a
233-
// candidate for eager reclaim. Only valid for humongous start
234-
// regions; other regions have unspecified values. Humongous start
235-
// regions are initialized at start of collection pause, with
236-
// candidates removed from the set as they are found reachable from
237-
// roots or the young generation.
238-
class HumongousReclaimCandidates : public G1BiasedMappedArray<bool> {
239-
protected:
240-
bool default_value() const override { return false; }
241-
public:
242-
void clear() { G1BiasedMappedArray<bool>::clear(); }
243-
void set_candidate(uint region, bool value) {
244-
set_by_index(region, value);
245-
}
246-
bool is_candidate(uint region) {
247-
return get_by_index(region);
248-
}
249-
};
250-
251-
HumongousReclaimCandidates _humongous_reclaim_candidates;
252232
uint _num_humongous_objects; // Current amount of (all) humongous objects found in the heap.
253233
uint _num_humongous_reclaim_candidates; // Number of humongous object eager reclaim candidates.
254234
public:
@@ -590,9 +570,6 @@ class G1CollectedHeap : public CollectedHeap {
590570
// Does the given region fulfill remembered set based eager reclaim candidate requirements?
591571
bool is_potential_eager_reclaim_candidate(HeapRegion* r) const;
592572

593-
// Modify the reclaim candidate set and test for presence.
594-
// These are only valid for starts_humongous regions.
595-
inline void set_humongous_reclaim_candidate(uint region, bool value);
596573
inline bool is_humongous_reclaim_candidate(uint region);
597574

598575
// Remove from the reclaim candidate set. Also remove from the

src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,30 +239,20 @@ inline bool G1CollectedHeap::is_obj_dead_full(const oop obj) const {
239239
return is_obj_dead_full(obj, heap_region_containing(obj));
240240
}
241241

242-
inline void G1CollectedHeap::set_humongous_reclaim_candidate(uint region, bool value) {
243-
assert(_hrm.at(region)->is_starts_humongous(), "Must start a humongous object");
244-
_humongous_reclaim_candidates.set_candidate(region, value);
245-
}
246-
247242
inline bool G1CollectedHeap::is_humongous_reclaim_candidate(uint region) {
248243
assert(_hrm.at(region)->is_starts_humongous(), "Must start a humongous object");
249-
return _humongous_reclaim_candidates.is_candidate(region);
244+
return _region_attr.is_humongous(region);
250245
}
251246

252247
inline void G1CollectedHeap::set_humongous_is_live(oop obj) {
253248
uint region = addr_to_region(cast_from_oop<HeapWord*>(obj));
254-
// Clear the flag in the humongous_reclaim_candidates table. Also
255-
// reset the entry in the region attribute table so that subsequent references
256-
// to the same humongous object do not go into the slow path again.
257-
// This is racy, as multiple threads may at the same time enter here, but this
258-
// is benign.
259-
// During collection we only ever clear the "candidate" flag, and only ever clear the
260-
// entry in the in_cset_fast_table.
261-
// We only ever evaluate the contents of these tables (in the VM thread) after
262-
// having synchronized the worker threads with the VM thread, or in the same
263-
// thread (i.e. within the VM thread).
264-
if (is_humongous_reclaim_candidate(region)) {
265-
set_humongous_reclaim_candidate(region, false);
249+
// Reset the entry in the region attribute table so that subsequent
250+
// references to the same humongous object do not go into the slow path
251+
// again. This is racy, as multiple threads may at the same time enter here,
252+
// but this is benign because the transition is unidirectional, from
253+
// humongous-candidate to not, and the write, in evacuation, is
254+
// separated from the read, in post-evacuation.
255+
if (_region_attr.is_humongous(region)) {
266256
_region_attr.clear_humongous(region);
267257
}
268258
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ class G1HeapRegionAttrBiasedMappedArray : public G1BiasedMappedArray<G1HeapRegio
142142
get_ref_by_index(index)->clear_humongous();
143143
}
144144

145+
bool is_humongous(uintptr_t index) {
146+
return get_ref_by_index(index)->is_humongous();
147+
}
148+
145149
void set_remset_is_tracked(uintptr_t index, bool remset_is_tracked) {
146150
get_ref_by_index(index)->set_remset_is_tracked(remset_is_tracked);
147151
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,10 @@ class G1PrepareEvacuationTask : public WorkerTask {
383383

384384
uint index = hr->hrm_index();
385385
if (humongous_region_is_candidate(hr)) {
386-
_g1h->set_humongous_reclaim_candidate(index, true);
387386
_g1h->register_humongous_region_with_region_attr(index);
388387
_worker_humongous_candidates++;
389388
// We will later handle the remembered sets of these regions.
390389
} else {
391-
_g1h->set_humongous_reclaim_candidate(index, false);
392390
_g1h->register_region_with_region_attr(hr);
393391
}
394392
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",

0 commit comments

Comments
 (0)