author | kbarrett |
Tue, 30 Aug 2016 23:48:16 -0400 | |
changeset 40892 | 330a02d935ad |
parent 37144 | b7ae74d4d5d8 |
permissions | -rw-r--r-- |
37144
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
1 |
/* |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
4 |
* |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
8 |
* |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
13 |
* accompanied this code). |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
14 |
* |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
18 |
* |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
21 |
* questions. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
22 |
* |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
23 |
*/ |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
24 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
26 |
#include "gc/g1/g1CollectedHeap.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
27 |
#include "gc/g1/g1HeapSizingPolicy.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
28 |
#include "gc/g1/g1Analytics.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
29 |
#include "logging/log.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
30 |
#include "runtime/globals.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
31 |
#include "utilities/debug.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
32 |
#include "utilities/globalDefinitions.hpp" |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
33 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
34 |
G1HeapSizingPolicy::G1HeapSizingPolicy(const G1CollectedHeap* g1, const G1Analytics* analytics) : |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
35 |
_g1(g1), |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
36 |
_analytics(analytics), |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
37 |
_num_prev_pauses_for_heuristics(analytics->number_of_recorded_pause_times()) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
38 |
assert(MinOverThresholdForGrowth < _num_prev_pauses_for_heuristics, "Threshold must be less than %u", _num_prev_pauses_for_heuristics); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
39 |
clear_ratio_check_data(); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
40 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
41 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
42 |
void G1HeapSizingPolicy::clear_ratio_check_data() { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
43 |
_ratio_over_threshold_count = 0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
44 |
_ratio_over_threshold_sum = 0.0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
45 |
_pauses_since_start = 0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
46 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
47 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
48 |
size_t G1HeapSizingPolicy::expansion_amount() { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
49 |
double recent_gc_overhead = _analytics->recent_avg_pause_time_ratio() * 100.0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
50 |
double last_gc_overhead = _analytics->last_pause_time_ratio() * 100.0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
51 |
assert(GCTimeRatio > 0, |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
52 |
"we should have set it to a default value set_g1_gc_flags() " |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
53 |
"if a user set it to 0"); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
54 |
const double gc_overhead_perc = 100.0 * (1.0 / (1.0 + GCTimeRatio)); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
55 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
56 |
double threshold = gc_overhead_perc; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
57 |
size_t expand_bytes = 0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
58 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
59 |
// If the heap is at less than half its maximum size, scale the threshold down, |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
60 |
// to a limit of 1. Thus the smaller the heap is, the more likely it is to expand, |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
61 |
// though the scaling code will likely keep the increase small. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
62 |
if (_g1->capacity() <= _g1->max_capacity() / 2) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
63 |
threshold *= (double)_g1->capacity() / (double)(_g1->max_capacity() / 2); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
64 |
threshold = MAX2(threshold, 1.0); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
65 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
66 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
67 |
// If the last GC time ratio is over the threshold, increment the count of |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
68 |
// times it has been exceeded, and add this ratio to the sum of exceeded |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
69 |
// ratios. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
70 |
if (last_gc_overhead > threshold) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
71 |
_ratio_over_threshold_count++; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
72 |
_ratio_over_threshold_sum += last_gc_overhead; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
73 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
74 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
75 |
// Check if we've had enough GC time ratio checks that were over the |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
76 |
// threshold to trigger an expansion. We'll also expand if we've |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
77 |
// reached the end of the history buffer and the average of all entries |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
78 |
// is still over the threshold. This indicates a smaller number of GCs were |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
79 |
// long enough to make the average exceed the threshold. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
80 |
bool filled_history_buffer = _pauses_since_start == _num_prev_pauses_for_heuristics; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
81 |
if ((_ratio_over_threshold_count == MinOverThresholdForGrowth) || |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
82 |
(filled_history_buffer && (recent_gc_overhead > threshold))) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
83 |
size_t min_expand_bytes = HeapRegion::GrainBytes; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
84 |
size_t reserved_bytes = _g1->max_capacity(); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
85 |
size_t committed_bytes = _g1->capacity(); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
86 |
size_t uncommitted_bytes = reserved_bytes - committed_bytes; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
87 |
size_t expand_bytes_via_pct = |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
88 |
uncommitted_bytes * G1ExpandByPercentOfAvailable / 100; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
89 |
double scale_factor = 1.0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
90 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
91 |
// If the current size is less than 1/4 of the Initial heap size, expand |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
92 |
// by half of the delta between the current and Initial sizes. IE, grow |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
93 |
// back quickly. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
94 |
// |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
95 |
// Otherwise, take the current size, or G1ExpandByPercentOfAvailable % of |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
96 |
// the available expansion space, whichever is smaller, as the base |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
97 |
// expansion size. Then possibly scale this size according to how much the |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
98 |
// threshold has (on average) been exceeded by. If the delta is small |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
99 |
// (less than the StartScaleDownAt value), scale the size down linearly, but |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
100 |
// not by less than MinScaleDownFactor. If the delta is large (greater than |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
101 |
// the StartScaleUpAt value), scale up, but adding no more than MaxScaleUpFactor |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
102 |
// times the base size. The scaling will be linear in the range from |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
103 |
// StartScaleUpAt to (StartScaleUpAt + ScaleUpRange). In other words, |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
104 |
// ScaleUpRange sets the rate of scaling up. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
105 |
if (committed_bytes < InitialHeapSize / 4) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
106 |
expand_bytes = (InitialHeapSize - committed_bytes) / 2; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
107 |
} else { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
108 |
double const MinScaleDownFactor = 0.2; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
109 |
double const MaxScaleUpFactor = 2; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
110 |
double const StartScaleDownAt = gc_overhead_perc; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
111 |
double const StartScaleUpAt = gc_overhead_perc * 1.5; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
112 |
double const ScaleUpRange = gc_overhead_perc * 2.0; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
113 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
114 |
double ratio_delta; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
115 |
if (filled_history_buffer) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
116 |
ratio_delta = recent_gc_overhead - threshold; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
117 |
} else { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
118 |
ratio_delta = (_ratio_over_threshold_sum/_ratio_over_threshold_count) - threshold; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
119 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
120 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
121 |
expand_bytes = MIN2(expand_bytes_via_pct, committed_bytes); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
122 |
if (ratio_delta < StartScaleDownAt) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
123 |
scale_factor = ratio_delta / StartScaleDownAt; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
124 |
scale_factor = MAX2(scale_factor, MinScaleDownFactor); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
125 |
} else if (ratio_delta > StartScaleUpAt) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
126 |
scale_factor = 1 + ((ratio_delta - StartScaleUpAt) / ScaleUpRange); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
127 |
scale_factor = MIN2(scale_factor, MaxScaleUpFactor); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
128 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
129 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
130 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
131 |
log_debug(gc, ergo, heap)("Attempt heap expansion (recent GC overhead higher than threshold after GC) " |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
132 |
"recent GC overhead: %1.2f %% threshold: %1.2f %% uncommitted: " SIZE_FORMAT "B base expansion amount and scale: " SIZE_FORMAT "B (%1.2f%%)", |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
133 |
recent_gc_overhead, threshold, uncommitted_bytes, expand_bytes, scale_factor * 100); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
134 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
135 |
expand_bytes = static_cast<size_t>(expand_bytes * scale_factor); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
136 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
137 |
// Ensure the expansion size is at least the minimum growth amount |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
138 |
// and at most the remaining uncommitted byte size. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
139 |
expand_bytes = MAX2(expand_bytes, min_expand_bytes); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
140 |
expand_bytes = MIN2(expand_bytes, uncommitted_bytes); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
141 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
142 |
clear_ratio_check_data(); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
143 |
} else { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
144 |
// An expansion was not triggered. If we've started counting, increment |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
145 |
// the number of checks we've made in the current window. If we've |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
146 |
// reached the end of the window without resizing, clear the counters to |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
147 |
// start again the next time we see a ratio above the threshold. |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
148 |
if (_ratio_over_threshold_count > 0) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
149 |
_pauses_since_start++; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
150 |
if (_pauses_since_start > _num_prev_pauses_for_heuristics) { |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
151 |
clear_ratio_check_data(); |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
152 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
153 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
154 |
} |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
155 |
|
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
156 |
return expand_bytes; |
b7ae74d4d5d8
8151808: Factor G1 heap sizing code out of the G1CollectorPolicy
mgerdin
parents:
diff
changeset
|
157 |
} |