< prev index next >
src/share/vm/gc/g1/g1CollectorPolicy.cpp
Print this page
rev 10472 : 8151711: Move G1 number sequences out of the G1 collector policy
Reviewed-by: tbenson, ehelin
rev 10473 : 8151637: Move CollectionSetChooser rebuild code into CollectionSetChooser
Reviewed-by:
rev 10474 : 8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
Reviewed-by:
@@ -47,11 +47,10 @@
_analytics(new G1Analytics(&_predictor)),
_pause_time_target_ms((double) MaxGCPauseMillis),
_rs_lengths_prediction(0),
_max_survivor_regions(0),
_survivors_age_table(true),
- _gc_overhead_perc(0.0),
_bytes_allocated_in_old_since_last_gc(0),
_ihop_control(NULL),
_initial_mark_to_mixed() {
@@ -74,12 +73,10 @@
// aligned with the region size. To get around this we use the
// unaligned values for the heap.
HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
HeapRegionRemSet::setup_remset_size();
- clear_ratio_check_data();
-
_phase_times = new G1GCPhaseTimes(ParallelGCThreads);
// Below, we might need to calculate the pause time target based on
// the pause interval. When we do so we are going to give G1 maximum
// flexibility and allow it to do pauses when it needs to. So, we'll
@@ -140,14 +137,10 @@
double time_slice = (double) GCPauseIntervalMillis / 1000.0;
_mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
_tenuring_threshold = MaxTenuringThreshold;
- assert(GCTimeRatio > 0,
- "we should have set it to a default value set_g1_gc_flags() "
- "if a user set it to 0");
- _gc_overhead_perc = 100.0 * (1.0 / (1.0 + GCTimeRatio));
uintx reserve_perc = G1ReservePercent;
// Put an artificial ceiling on this so that it's not set to a silly value.
if (reserve_perc > 50) {
reserve_perc = 50;
@@ -1081,121 +1074,10 @@
region_elapsed_time_ms += _analytics->predict_non_young_other_time_ms(1);
}
return region_elapsed_time_ms;
}
-void G1CollectorPolicy::clear_ratio_check_data() {
- _ratio_over_threshold_count = 0;
- _ratio_over_threshold_sum = 0.0;
- _pauses_since_start = 0;
-}
-
-size_t G1CollectorPolicy::expansion_amount() {
- double recent_gc_overhead = _analytics->recent_avg_pause_time_ratio() * 100.0;
- double last_gc_overhead = _analytics->last_pause_time_ratio() * 100.0;
- double threshold = _gc_overhead_perc;
- size_t expand_bytes = 0;
-
- // If the heap is at less than half its maximum size, scale the threshold down,
- // to a limit of 1. Thus the smaller the heap is, the more likely it is to expand,
- // though the scaling code will likely keep the increase small.
- if (_g1->capacity() <= _g1->max_capacity() / 2) {
- threshold *= (double)_g1->capacity() / (double)(_g1->max_capacity() / 2);
- threshold = MAX2(threshold, 1.0);
- }
-
- // If the last GC time ratio is over the threshold, increment the count of
- // times it has been exceeded, and add this ratio to the sum of exceeded
- // ratios.
- if (last_gc_overhead > threshold) {
- _ratio_over_threshold_count++;
- _ratio_over_threshold_sum += last_gc_overhead;
- }
-
- // Check if we've had enough GC time ratio checks that were over the
- // threshold to trigger an expansion. We'll also expand if we've
- // reached the end of the history buffer and the average of all entries
- // is still over the threshold. This indicates a smaller number of GCs were
- // long enough to make the average exceed the threshold.
- bool filled_history_buffer = _pauses_since_start == NumPrevPausesForHeuristics;
- if ((_ratio_over_threshold_count == MinOverThresholdForGrowth) ||
- (filled_history_buffer && (recent_gc_overhead > threshold))) {
- size_t min_expand_bytes = HeapRegion::GrainBytes;
- size_t reserved_bytes = _g1->max_capacity();
- size_t committed_bytes = _g1->capacity();
- size_t uncommitted_bytes = reserved_bytes - committed_bytes;
- size_t expand_bytes_via_pct =
- uncommitted_bytes * G1ExpandByPercentOfAvailable / 100;
- double scale_factor = 1.0;
-
- // If the current size is less than 1/4 of the Initial heap size, expand
- // by half of the delta between the current and Initial sizes. IE, grow
- // back quickly.
- //
- // Otherwise, take the current size, or G1ExpandByPercentOfAvailable % of
- // the available expansion space, whichever is smaller, as the base
- // expansion size. Then possibly scale this size according to how much the
- // threshold has (on average) been exceeded by. If the delta is small
- // (less than the StartScaleDownAt value), scale the size down linearly, but
- // not by less than MinScaleDownFactor. If the delta is large (greater than
- // the StartScaleUpAt value), scale up, but adding no more than MaxScaleUpFactor
- // times the base size. The scaling will be linear in the range from
- // StartScaleUpAt to (StartScaleUpAt + ScaleUpRange). In other words,
- // ScaleUpRange sets the rate of scaling up.
- if (committed_bytes < InitialHeapSize / 4) {
- expand_bytes = (InitialHeapSize - committed_bytes) / 2;
- } else {
- double const MinScaleDownFactor = 0.2;
- double const MaxScaleUpFactor = 2;
- double const StartScaleDownAt = _gc_overhead_perc;
- double const StartScaleUpAt = _gc_overhead_perc * 1.5;
- double const ScaleUpRange = _gc_overhead_perc * 2.0;
-
- double ratio_delta;
- if (filled_history_buffer) {
- ratio_delta = recent_gc_overhead - threshold;
- } else {
- ratio_delta = (_ratio_over_threshold_sum/_ratio_over_threshold_count) - threshold;
- }
-
- expand_bytes = MIN2(expand_bytes_via_pct, committed_bytes);
- if (ratio_delta < StartScaleDownAt) {
- scale_factor = ratio_delta / StartScaleDownAt;
- scale_factor = MAX2(scale_factor, MinScaleDownFactor);
- } else if (ratio_delta > StartScaleUpAt) {
- scale_factor = 1 + ((ratio_delta - StartScaleUpAt) / ScaleUpRange);
- scale_factor = MIN2(scale_factor, MaxScaleUpFactor);
- }
- }
-
- log_debug(gc, ergo, heap)("Attempt heap expansion (recent GC overhead higher than threshold after GC) "
- "recent GC overhead: %1.2f %% threshold: %1.2f %% uncommitted: " SIZE_FORMAT "B base expansion amount and scale: " SIZE_FORMAT "B (%1.2f%%)",
- recent_gc_overhead, threshold, uncommitted_bytes, expand_bytes, scale_factor * 100);
-
- expand_bytes = static_cast<size_t>(expand_bytes * scale_factor);
-
- // Ensure the expansion size is at least the minimum growth amount
- // and at most the remaining uncommitted byte size.
- expand_bytes = MAX2(expand_bytes, min_expand_bytes);
- expand_bytes = MIN2(expand_bytes, uncommitted_bytes);
-
- clear_ratio_check_data();
- } else {
- // An expansion was not triggered. If we've started counting, increment
- // the number of checks we've made in the current window. If we've
- // reached the end of the window without resizing, clear the counters to
- // start again the next time we see a ratio above the threshold.
- if (_ratio_over_threshold_count > 0) {
- _pauses_since_start++;
- if (_pauses_since_start > NumPrevPausesForHeuristics) {
- clear_ratio_check_data();
- }
- }
- }
-
- return expand_bytes;
-}
void G1CollectorPolicy::print_yg_surv_rate_info() const {
#ifndef PRODUCT
_short_lived_surv_rate_group->print_surv_rate_summary();
// add this call for any other surv rate groups
< prev index next >