414 if (!collector_state()->gcs_are_young()) {
415 cset_chooser()->verify();
416 const uint min_old_cset_length = _policy->calc_min_old_cset_length();
417 const uint max_old_cset_length = _policy->calc_max_old_cset_length();
418
419 uint expensive_region_num = 0;
420 bool check_time_remaining = _policy->adaptive_young_list_length();
421
422 HeapRegion* hr = cset_chooser()->peek();
423 while (hr != NULL) {
424 if (old_region_length() >= max_old_cset_length) {
425 // Added maximum number of old regions to the CSet.
426 log_debug(gc, ergo, cset)("Finish adding old regions to CSet (old CSet region num reached max). old %u regions, max %u regions",
427 old_region_length(), max_old_cset_length);
428 break;
429 }
430
431 // Stop adding regions if the remaining reclaimable space is
432 // not above G1HeapWastePercent.
433 size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes();
434 double reclaimable_perc = _policy->reclaimable_bytes_perc(reclaimable_bytes);
435 double threshold = (double) G1HeapWastePercent;
436 if (reclaimable_perc <= threshold) {
437 // We've added enough old regions that the amount of uncollected
438 // reclaimable space is at or below the waste threshold. Stop
439 // adding old regions to the CSet.
440 log_debug(gc, ergo, cset)("Finish adding old regions to CSet (reclaimable percentage not over threshold). "
441 "old %u regions, max %u regions, reclaimable: " SIZE_FORMAT "B (%1.2f%%) threshold: " UINTX_FORMAT "%%",
442 old_region_length(), max_old_cset_length, reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
443 break;
444 }
445
446 double predicted_time_ms = predict_region_elapsed_time_ms(hr);
447 if (check_time_remaining) {
448 if (predicted_time_ms > time_remaining_ms) {
449 // Too expensive for the current CSet.
450
451 if (old_region_length() >= min_old_cset_length) {
452 // We have added the minimum number of old regions to the CSet,
453 // we are done with this CSet.
454 log_debug(gc, ergo, cset)("Finish adding old regions to CSet (predicted time is too high). "
455 "predicted time: %1.2fms, remaining time: %1.2fms old %u regions, min %u regions",
456 predicted_time_ms, time_remaining_ms, old_region_length(), min_old_cset_length);
457 break;
458 }
459
460 // We'll add it anyway given that we haven't reached the
461 // minimum number of old regions.
462 expensive_region_num += 1;
|
414 if (!collector_state()->gcs_are_young()) {
415 cset_chooser()->verify();
416 const uint min_old_cset_length = _policy->calc_min_old_cset_length();
417 const uint max_old_cset_length = _policy->calc_max_old_cset_length();
418
419 uint expensive_region_num = 0;
420 bool check_time_remaining = _policy->adaptive_young_list_length();
421
422 HeapRegion* hr = cset_chooser()->peek();
423 while (hr != NULL) {
424 if (old_region_length() >= max_old_cset_length) {
425 // Added maximum number of old regions to the CSet.
426 log_debug(gc, ergo, cset)("Finish adding old regions to CSet (old CSet region num reached max). old %u regions, max %u regions",
427 old_region_length(), max_old_cset_length);
428 break;
429 }
430
431 // Stop adding regions if the remaining reclaimable space is
432 // not above G1HeapWastePercent.
433 size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes();
434 double reclaimable_percent = _policy->reclaimable_bytes_percent(reclaimable_bytes);
435 double threshold = (double) G1HeapWastePercent;
436 if (reclaimable_percent <= threshold) {
437 // We've added enough old regions that the amount of uncollected
438 // reclaimable space is at or below the waste threshold. Stop
439 // adding old regions to the CSet.
440 log_debug(gc, ergo, cset)("Finish adding old regions to CSet (reclaimable percentage not over threshold). "
441 "old %u regions, max %u regions, reclaimable: " SIZE_FORMAT "B (%1.2f%%) threshold: " UINTX_FORMAT "%%",
442 old_region_length(), max_old_cset_length, reclaimable_bytes, reclaimable_percent, G1HeapWastePercent);
443 break;
444 }
445
446 double predicted_time_ms = predict_region_elapsed_time_ms(hr);
447 if (check_time_remaining) {
448 if (predicted_time_ms > time_remaining_ms) {
449 // Too expensive for the current CSet.
450
451 if (old_region_length() >= min_old_cset_length) {
452 // We have added the minimum number of old regions to the CSet,
453 // we are done with this CSet.
454 log_debug(gc, ergo, cset)("Finish adding old regions to CSet (predicted time is too high). "
455 "predicted time: %1.2fms, remaining time: %1.2fms old %u regions, min %u regions",
456 predicted_time_ms, time_remaining_ms, old_region_length(), min_old_cset_length);
457 break;
458 }
459
460 // We'll add it anyway given that we haven't reached the
461 // minimum number of old regions.
462 expensive_region_num += 1;
|