23
23
*/
24
24
25
25
#include " precompiled.hpp"
26
+ #include " gc/g1/g1Analytics.hpp"
26
27
#include " gc/g1/g1CollectedHeap.inline.hpp"
27
28
#include " gc/g1/g1CollectionSet.hpp"
28
29
#include " gc/g1/g1CollectionSetCandidates.hpp"
@@ -47,10 +48,6 @@ G1GCPhaseTimes* G1CollectionSet::phase_times() {
47
48
return _policy->phase_times ();
48
49
}
49
50
50
- double G1CollectionSet::predict_region_non_copy_time_ms (HeapRegion* hr) const {
51
- return _policy->predict_region_non_copy_time_ms (hr, collector_state ()->in_young_only_phase ());
52
- }
53
-
54
51
G1CollectionSet::G1CollectionSet (G1CollectedHeap* g1h, G1Policy* policy) :
55
52
_g1h(g1h),
56
53
_policy(policy),
@@ -63,20 +60,13 @@ G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
63
60
_collection_set_max_length(0 ),
64
61
_num_optional_regions(0 ),
65
62
_bytes_used_before(0 ),
66
- _recorded_rs_length(0 ),
67
63
_inc_build_state(Inactive),
68
64
_inc_part_start(0 ),
69
- _inc_collection_set_stats(NULL ),
70
- _inc_bytes_used_before(0 ),
71
- _inc_recorded_rs_length(0 ),
72
- _inc_recorded_rs_length_diff(0 ),
73
- _inc_predicted_non_copy_time_ms(0.0 ),
74
- _inc_predicted_non_copy_time_ms_diff(0.0 ) {
65
+ _inc_bytes_used_before(0 ) {
75
66
}
76
67
77
68
G1CollectionSet::~G1CollectionSet () {
78
69
FREE_C_HEAP_ARRAY (uint , _collection_set_regions);
79
- FREE_C_HEAP_ARRAY (IncCollectionSetRegionStat, _inc_collection_set_stats);
80
70
free_optional_regions ();
81
71
clear_candidates ();
82
72
}
@@ -99,7 +89,6 @@ void G1CollectionSet::initialize(uint max_region_length) {
99
89
guarantee (_collection_set_regions == NULL , " Must only initialize once." );
100
90
_collection_set_max_length = max_region_length;
101
91
_collection_set_regions = NEW_C_HEAP_ARRAY (uint , max_region_length, mtGC);
102
- _inc_collection_set_stats = NEW_C_HEAP_ARRAY (IncCollectionSetRegionStat, max_region_length, mtGC);
103
92
}
104
93
105
94
void G1CollectionSet::free_optional_regions () {
@@ -115,10 +104,6 @@ bool G1CollectionSet::has_candidates() {
115
104
return _candidates != NULL && !_candidates->is_empty ();
116
105
}
117
106
118
- void G1CollectionSet::set_recorded_rs_length (size_t rs_length) {
119
- _recorded_rs_length = rs_length;
120
- }
121
-
122
107
// Add the heap region at the head of the non-incremental collection set
123
108
void G1CollectionSet::add_old_region (HeapRegion* hr) {
124
109
assert_at_safepoint_on_vm_thread ();
@@ -134,7 +119,6 @@ void G1CollectionSet::add_old_region(HeapRegion* hr) {
134
119
_collection_set_regions[_collection_set_cur_length++] = hr->hrm_index ();
135
120
136
121
_bytes_used_before += hr->used ();
137
- _recorded_rs_length += hr->rem_set ()->occupied ();
138
122
_old_region_length++;
139
123
140
124
_g1h->old_set_remove (hr);
@@ -152,38 +136,15 @@ void G1CollectionSet::add_optional_region(HeapRegion* hr) {
152
136
void G1CollectionSet::start_incremental_building () {
153
137
assert (_collection_set_cur_length == 0 , " Collection set must be empty before starting a new collection set." );
154
138
assert (_inc_build_state == Inactive, " Precondition" );
155
- #ifdef ASSERT
156
- for (uint i = 0 ; i < _collection_set_max_length; i++) {
157
- _inc_collection_set_stats[i].reset ();
158
- }
159
- #endif
160
139
161
140
_inc_bytes_used_before = 0 ;
162
141
163
- _inc_recorded_rs_length = 0 ;
164
- _inc_recorded_rs_length_diff = 0 ;
165
- _inc_predicted_non_copy_time_ms = 0.0 ;
166
- _inc_predicted_non_copy_time_ms_diff = 0.0 ;
167
-
168
142
update_incremental_marker ();
169
143
}
170
144
171
145
void G1CollectionSet::finalize_incremental_building () {
172
146
assert (_inc_build_state == Active, " Precondition" );
173
147
assert (SafepointSynchronize::is_at_safepoint (), " should be at a safepoint" );
174
-
175
- // The two "main" fields, _inc_recorded_rs_length and
176
- // _inc_predicted_non_copy_time_ms, are updated by the thread
177
- // that adds a new region to the CSet. Further updates by the
178
- // concurrent refinement thread that samples the young RSet lengths
179
- // are accumulated in the *_diff fields. Here we add the diffs to
180
- // the "main" fields.
181
-
182
- _inc_recorded_rs_length += _inc_recorded_rs_length_diff;
183
- _inc_predicted_non_copy_time_ms += _inc_predicted_non_copy_time_ms_diff;
184
-
185
- _inc_recorded_rs_length_diff = 0 ;
186
- _inc_predicted_non_copy_time_ms_diff = 0.0 ;
187
148
}
188
149
189
150
void G1CollectionSet::clear () {
@@ -239,31 +200,6 @@ void G1CollectionSet::iterate_part_from(HeapRegionClosure* cl,
239
200
worker_id);
240
201
}
241
202
242
- void G1CollectionSet::update_young_region_prediction (HeapRegion* hr,
243
- size_t new_rs_length) {
244
- // Update the CSet information that is dependent on the new RS length
245
- assert (hr->is_young (), " Precondition" );
246
- assert (!SafepointSynchronize::is_at_safepoint (), " should not be at a safepoint" );
247
-
248
- IncCollectionSetRegionStat* stat = &_inc_collection_set_stats[hr->hrm_index ()];
249
-
250
- size_t old_rs_length = stat->_rs_length ;
251
- assert (old_rs_length <= new_rs_length,
252
- " Remembered set decreased (changed from " SIZE_FORMAT " to " SIZE_FORMAT " region %u type %s)" ,
253
- old_rs_length, new_rs_length, hr->hrm_index (), hr->get_short_type_str ());
254
- size_t rs_length_diff = new_rs_length - old_rs_length;
255
- stat->_rs_length = new_rs_length;
256
- _inc_recorded_rs_length_diff += rs_length_diff;
257
-
258
- double old_non_copy_time = stat->_non_copy_time_ms ;
259
- assert (old_non_copy_time >= 0.0 , " Non copy time for region %u not initialized yet, is %.3f" , hr->hrm_index (), old_non_copy_time);
260
- double new_non_copy_time = predict_region_non_copy_time_ms (hr);
261
- double non_copy_time_ms_diff = new_non_copy_time - old_non_copy_time;
262
-
263
- stat->_non_copy_time_ms = new_non_copy_time;
264
- _inc_predicted_non_copy_time_ms_diff += non_copy_time_ms_diff;
265
- }
266
-
267
203
void G1CollectionSet::add_young_region_common (HeapRegion* hr) {
268
204
assert (hr->is_young (), " invariant" );
269
205
assert (_inc_build_state == Active, " Precondition" );
@@ -285,20 +221,6 @@ void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
285
221
// Ignore calls to this due to retirement during full gc.
286
222
287
223
if (!_g1h->collector_state ()->in_full_gc ()) {
288
- size_t rs_length = hr->rem_set ()->occupied ();
289
- double non_copy_time = predict_region_non_copy_time_ms (hr);
290
-
291
- // Cache the values we have added to the aggregated information
292
- // in the heap region in case we have to remove this region from
293
- // the incremental collection set, or it is updated by the
294
- // rset sampling code
295
-
296
- IncCollectionSetRegionStat* stat = &_inc_collection_set_stats[hr->hrm_index ()];
297
- stat->_rs_length = rs_length;
298
- stat->_non_copy_time_ms = non_copy_time;
299
-
300
- _inc_recorded_rs_length += rs_length;
301
- _inc_predicted_non_copy_time_ms += non_copy_time;
302
224
_inc_bytes_used_before += hr->used ();
303
225
}
304
226
@@ -400,7 +322,8 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi
400
322
guarantee (target_pause_time_ms > 0.0 ,
401
323
" target_pause_time_ms = %1.6lf should be positive" , target_pause_time_ms);
402
324
403
- size_t pending_cards = _policy->pending_cards_at_gc_start () + _g1h->hot_card_cache ()->num_entries ();
325
+ size_t pending_cards = _policy->pending_cards_at_gc_start () +
326
+ _g1h->hot_card_cache ()->num_entries ();
404
327
405
328
log_trace (gc, ergo, cset)(" Start choosing CSet. Pending cards: " SIZE_FORMAT " target pause time: %1.2fms" ,
406
329
pending_cards, target_pause_time_ms);
@@ -417,12 +340,11 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi
417
340
418
341
_bytes_used_before = _inc_bytes_used_before;
419
342
420
- // The number of recorded young regions is the incremental
421
- // collection set's current size
422
- set_recorded_rs_length (_inc_recorded_rs_length);
423
-
424
343
double predicted_base_time_ms = _policy->predict_base_time_ms (pending_cards);
425
- double predicted_eden_time = _inc_predicted_non_copy_time_ms + _policy->predict_eden_copy_time_ms (eden_region_length);
344
+ // Base time already includes the whole remembered set related time, so do not add that here
345
+ // again.
346
+ double predicted_eden_time = _policy->predict_young_region_other_time_ms (eden_region_length) +
347
+ _policy->predict_eden_copy_time_ms (eden_region_length);
426
348
double remaining_time_ms = MAX2 (target_pause_time_ms - (predicted_base_time_ms + predicted_eden_time), 0.0 );
427
349
428
350
log_trace (gc, ergo, cset)(" Added young regions to CSet. Eden: %u regions, Survivors: %u regions, "
0 commit comments