Skip to content

Commit 02c78bb

Browse files
author
Thomas Schatzl
committed
8367731: G1: Make G1CollectionSet manage the young gen cset group
Reviewed-by: iwalulya, ayang
1 parent dbf787c commit 02c78bb

File tree

8 files changed

+36
-39
lines changed

8 files changed

+36
-39
lines changed

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

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,13 +2517,7 @@ void G1CollectedHeap::update_perf_counter_cpu_time() {
25172517
}
25182518

25192519
void G1CollectedHeap::start_new_collection_set() {
2520-
// Clear current young cset group to allow adding.
2521-
// It is fine to clear it this late - evacuation does not add any remembered sets
2522-
// by itself, but only marks cards.
2523-
// The regions had their association to this group already removed earlier.
2524-
young_regions_cset_group()->clear();
2525-
2526-
collection_set()->start_incremental_building();
2520+
collection_set()->start();
25272521

25282522
clear_region_attr();
25292523

@@ -2879,12 +2873,7 @@ void G1CollectedHeap::abandon_collection_set() {
28792873
G1AbandonCollectionSetClosure cl;
28802874
collection_set_iterate_all(&cl);
28812875

2882-
collection_set()->clear();
2883-
collection_set()->stop_incremental_building();
2884-
2885-
collection_set()->abandon_all_candidates();
2886-
2887-
young_regions_cset_group()->clear(true /* uninstall_group_cardset */);
2876+
collection_set()->abandon();
28882877
}
28892878

28902879
bool G1CollectedHeap::is_old_gc_alloc_region(G1HeapRegion* hr) {
@@ -3247,9 +3236,3 @@ void G1CollectedHeap::finish_codecache_marking_cycle() {
32473236
CodeCache::on_gc_marking_cycle_finish();
32483237
CodeCache::arm_all_nmethods();
32493238
}
3250-
3251-
void G1CollectedHeap::prepare_group_cardsets_for_scan() {
3252-
young_regions_cardset()->reset_table_scanner_for_groups();
3253-
3254-
collection_set()->prepare_for_scan();
3255-
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,6 @@ class G1CollectedHeap : public CollectedHeap {
805805
G1CardSetConfiguration* card_set_config() { return &_card_set_config; }
806806

807807
G1CSetCandidateGroup* young_regions_cset_group() { return &_young_regions_cset_group; }
808-
G1CardSet* young_regions_cardset() { return _young_regions_cset_group.card_set(); };
809-
810-
G1MonotonicArenaMemoryStats young_regions_card_set_memory_stats() { return _young_regions_cset_group.card_set_memory_stats(); }
811-
812-
void prepare_group_cardsets_for_scan();
813808

814809
// After a collection pause, reset eden and the collection set.
815810
void clear_eden();

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,21 @@ void G1CollectionSet::initialize(uint max_region_length) {
9999
_candidates.initialize(max_region_length);
100100
}
101101

102+
void G1CollectionSet::abandon() {
103+
_g1h->young_regions_cset_group()->clear(true /* uninstall_cset_group */);
104+
clear();
105+
abandon_all_candidates();
106+
107+
stop_incremental_building();
108+
}
109+
102110
void G1CollectionSet::abandon_all_candidates() {
103111
_candidates.clear();
104112
_initial_old_region_length = 0;
105113
}
106114

107115
void G1CollectionSet::prepare_for_scan () {
116+
_g1h->young_regions_cset_group()->card_set()->reset_table_scanner_for_groups();
108117
_groups.prepare_for_scan();
109118
}
110119

@@ -127,12 +136,15 @@ void G1CollectionSet::add_old_region(G1HeapRegion* hr) {
127136
_g1h->old_set_remove(hr);
128137
}
129138

130-
void G1CollectionSet::start_incremental_building() {
139+
void G1CollectionSet::start() {
131140
assert(_regions_cur_length == 0, "Collection set must be empty before starting a new collection set.");
132141
assert(groups_cur_length() == 0, "Collection set groups must be empty before starting a new collection set.");
133142
assert(_optional_groups.length() == 0, "Collection set optional gorups must be empty before starting a new collection set.");
134143

135144
continue_incremental_building();
145+
146+
G1CSetCandidateGroup* young_group = _g1h->young_regions_cset_group();
147+
young_group->clear();
136148
}
137149

138150
void G1CollectionSet::continue_incremental_building() {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,16 @@ class G1CollectionSet {
227227
uint& num_optional_regions,
228228
double& predicted_optional_time_ms,
229229
double predicted_time_ms);
230+
230231
public:
231232
G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy);
232233
~G1CollectionSet();
233234

234235
// Initializes the collection set giving the maximum possible length of the collection set.
235236
void initialize(uint max_region_length);
236237

238+
// Drop the collection set and collection set candidates.
239+
void abandon();
237240
// Drop all collection set candidates (only the candidates).
238241
void abandon_all_candidates();
239242

@@ -261,13 +264,15 @@ class G1CollectionSet {
261264
template <class CardOrRangeVisitor>
262265
inline void merge_cardsets_for_collection_groups(CardOrRangeVisitor& cl, uint worker_id, uint num_workers);
263266

267+
uint groups_increment_length() const;
268+
264269
// Reset the contents of the collection set.
265270
void clear();
266271

267272
// Incremental collection set support
268273

269-
// Initialize incremental collection set info.
270-
void start_incremental_building();
274+
// Start a new collection set for the next mutator phase.
275+
void start();
271276
// Start a new collection set increment, continuing the incremental building.
272277
void continue_incremental_building();
273278
// Stop adding regions to the current collection set increment.
@@ -282,8 +287,6 @@ class G1CollectionSet {
282287
// Returns the length of the whole current collection set in number of regions
283288
size_t cur_length() const { return _regions_cur_length; }
284289

285-
uint groups_increment_length() const;
286-
287290
// Iterate over the entire collection set (all increments calculated so far), applying
288291
// the given G1HeapRegionClosure on all of the regions.
289292
void iterate(G1HeapRegionClosure* cl) const;

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,24 @@
3131

3232
template <class CardOrRangeVisitor>
3333
inline void G1CollectionSet::merge_cardsets_for_collection_groups(CardOrRangeVisitor& cl, uint worker_id, uint num_workers) {
34-
uint length = groups_increment_length();
3534
uint offset = _groups_inc_part_start;
36-
if (length == 0) {
35+
if (offset == 0) {
36+
G1HeapRegionRemSet::iterate_for_merge(_g1h->young_regions_cset_group()->card_set(), cl);
37+
}
38+
39+
uint next_increment_length = groups_increment_length();
40+
if (next_increment_length == 0) {
3741
return;
3842
}
3943

40-
uint start_pos = (worker_id * length) / num_workers;
44+
uint start_pos = (worker_id * next_increment_length) / num_workers;
4145
uint cur_pos = start_pos;
4246
uint count = 0;
4347
do {
4448
G1HeapRegionRemSet::iterate_for_merge(_groups.at(offset + cur_pos)->card_set(), cl);
4549
cur_pos++;
4650
count++;
47-
if (cur_pos == length) {
51+
if (cur_pos == next_increment_length) {
4852
cur_pos = 0;
4953
}
5054
} while (cur_pos != start_pos);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class G1CSetCandidateGroup : public CHeapObj<mtGCCardSet>{
122122
return _card_set_mm.memory_stats();
123123
}
124124

125+
size_t cards_occupied() const {
126+
return _card_set.occupied();
127+
}
128+
125129
void clear(bool uninstall_group_cardset = false);
126130

127131
G1CSetCandidateGroupIterator begin() const {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,6 @@ class G1MergeHeapRootsTask : public WorkerTask {
11661166
// 2. collection set
11671167
G1MergeCardSetClosure merge(_scan_state);
11681168

1169-
if (_initial_evacuation) {
1170-
G1HeapRegionRemSet::iterate_for_merge(g1h->young_regions_cardset(), merge);
1171-
}
1172-
11731169
g1h->collection_set()->merge_cardsets_for_collection_groups(merge, worker_id, _num_workers);
11741170

11751171
G1MergeCardSetStats stats = merge.stats();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void G1YoungCollector::pre_evacuate_collection_set(G1EvacInfo* evacuation_info)
506506
Ticks start = Ticks::now();
507507
rem_set()->prepare_for_scan_heap_roots();
508508

509-
_g1h->prepare_group_cardsets_for_scan();
509+
_g1h->collection_set()->prepare_for_scan();
510510

511511
phase_times()->record_prepare_heap_roots_time_ms((Ticks::now() - start).seconds() * 1000.0);
512512
}
@@ -516,7 +516,7 @@ void G1YoungCollector::pre_evacuate_collection_set(G1EvacInfo* evacuation_info)
516516
Tickspan task_time = run_task_timed(&g1_prep_task);
517517

518518
G1MonotonicArenaMemoryStats sampled_card_set_stats = g1_prep_task.all_card_set_stats();
519-
sampled_card_set_stats.add(_g1h->young_regions_card_set_memory_stats());
519+
sampled_card_set_stats.add(_g1h->young_regions_cset_group()->card_set_memory_stats());
520520
_g1h->set_young_gen_card_set_stats(sampled_card_set_stats);
521521
_g1h->set_humongous_stats(g1_prep_task.humongous_total(), g1_prep_task.humongous_candidates());
522522

0 commit comments

Comments
 (0)