@@ -190,17 +190,14 @@ uint G1Policy::calculate_desired_eden_length_by_mmu() const {
190
190
void G1Policy::update_young_length_bounds () {
191
191
assert (!Universe::is_fully_initialized () || SafepointSynchronize::is_at_safepoint (), " must be" );
192
192
bool for_young_only_phase = collector_state ()->in_young_only_phase ();
193
- // Request at least one eden region to ensure progress.
194
- bool after_gc = true ;
195
193
update_young_length_bounds (_analytics->predict_pending_cards (for_young_only_phase),
196
- _analytics->predict_rs_length (for_young_only_phase),
197
- after_gc);
194
+ _analytics->predict_rs_length (for_young_only_phase));
198
195
}
199
196
200
- void G1Policy::update_young_length_bounds (size_t pending_cards, size_t rs_length, bool after_gc ) {
197
+ void G1Policy::update_young_length_bounds (size_t pending_cards, size_t rs_length) {
201
198
uint old_young_list_target_length = young_list_target_length ();
202
199
203
- uint new_young_list_desired_length = calculate_young_desired_length (pending_cards, rs_length, after_gc );
200
+ uint new_young_list_desired_length = calculate_young_desired_length (pending_cards, rs_length);
204
201
uint new_young_list_target_length = calculate_young_target_length (new_young_list_desired_length);
205
202
uint new_young_list_max_length = calculate_young_max_length (new_young_list_target_length);
206
203
@@ -239,7 +236,7 @@ void G1Policy::update_young_length_bounds(size_t pending_cards, size_t rs_length
239
236
// value smaller than what is already allocated or what can actually be allocated.
240
237
// This return value is only an expectation.
241
238
//
242
- uint G1Policy::calculate_young_desired_length (size_t pending_cards, size_t rs_length, bool after_gc ) const {
239
+ uint G1Policy::calculate_young_desired_length (size_t pending_cards, size_t rs_length) const {
243
240
uint min_young_length_by_sizer = _young_gen_sizer.min_desired_young_length ();
244
241
uint max_young_length_by_sizer = _young_gen_sizer.max_desired_young_length ();
245
242
@@ -253,18 +250,18 @@ uint G1Policy::calculate_young_desired_length(size_t pending_cards, size_t rs_le
253
250
// Size of the already allocated young gen.
254
251
const uint allocated_young_length = _g1h->young_regions_count ();
255
252
// This is the absolute minimum young length that we can return. Ensure that we
256
- // don't go below any user-defined minimum bound; but we might have already
257
- // allocated more than that for various reasons. In this case, use that.
258
- uint absolute_min_young_length = MAX2 (allocated_young_length, min_young_length_by_sizer);
253
+ // don't go below any user-defined minimum bound. Also, we must have at least
254
+ // one eden region, to ensure progress. But when revising during the ensuing
255
+ // mutator phase we might have already allocated more than either of those, in
256
+ // which case use that.
257
+ uint absolute_min_young_length = MAX3 (min_young_length_by_sizer,
258
+ survivor_length + 1 ,
259
+ allocated_young_length);
259
260
// Calculate the absolute max bounds. After evac failure or when revising the
260
261
// young length we might have exceeded absolute min length or absolute_max_length,
261
262
// so adjust the result accordingly.
262
263
uint absolute_max_young_length = MAX2 (max_young_length_by_sizer, absolute_min_young_length);
263
264
264
- // The absolute minimum young gen length (as provided by the young gen sizer) ensures
265
- // that we desire at least one young gen region.
266
- assert (absolute_min_young_length > 0 , " must be" );
267
-
268
265
uint desired_eden_length_by_mmu = 0 ;
269
266
uint desired_eden_length_by_pause = 0 ;
270
267
@@ -293,28 +290,14 @@ uint G1Policy::calculate_young_desired_length(size_t pending_cards, size_t rs_le
293
290
// Clamp to absolute min/max after we determined desired lengths.
294
291
desired_young_length = clamp (desired_young_length, absolute_min_young_length, absolute_max_young_length);
295
292
296
- // After a garbage collection, make room for at least one eden region (i.e. in addition to
297
- // already allocated survivor regions).
298
- // This may make desired regions go over absolute maximum length by the heap sizer, however
299
- // the immediate full gcs after that young gc (particularly on small heaps) are worse.
300
- if (after_gc && (allocated_young_length >= desired_young_length)) {
301
- log_trace (gc, ergo, heap)(" Young desired length: Desired young region length less than already "
302
- " allocated region length, but requesting one eden region minimum. "
303
- " Expanding desired young length from %u to %u." ,
304
- desired_young_length,
305
- allocated_young_length + 1 );
306
- desired_young_length = allocated_young_length + 1 ;
307
- }
308
-
309
- log_trace (gc, ergo, heap)(" Young desired length %u (after gc: %s) "
293
+ log_trace (gc, ergo, heap)(" Young desired length %u "
310
294
" survivor length %u "
311
295
" allocated young length %u "
312
296
" absolute min young length %u "
313
297
" absolute max young length %u "
314
298
" desired eden length by mmu %u "
315
299
" desired eden length by pause %u " ,
316
- desired_young_length, BOOL_TO_STR (after_gc),
317
- survivor_length,
300
+ desired_young_length, survivor_length,
318
301
allocated_young_length, absolute_min_young_length,
319
302
absolute_max_young_length, desired_eden_length_by_mmu,
320
303
desired_eden_length_by_pause);
@@ -548,10 +531,7 @@ void G1Policy::revise_young_list_target_length(size_t rs_length) {
548
531
size_t thread_buffer_cards = _analytics->predict_dirtied_cards_in_thread_buffers ();
549
532
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set ();
550
533
size_t pending_cards = dcqs.num_cards () + thread_buffer_cards;
551
- // We are only revising young gen length to meet pause time goal, so do not request
552
- // at least one eden region for progress. At this point we actually want to run into
553
- // a GC soon if young gen is already (too) large.
554
- update_young_length_bounds (pending_cards, rs_length, false /* need_one_eden_region */ );
534
+ update_young_length_bounds (pending_cards, rs_length);
555
535
}
556
536
557
537
void G1Policy::record_full_collection_start () {
0 commit comments