annotate src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children f08d439fab8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1284
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1284
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1284
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/shared/gcStats.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/defNewGeneration.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/genCollectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/thread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #ifdef TARGET_OS_FAMILY_linux
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 # include "os_linux.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #ifdef TARGET_OS_FAMILY_solaris
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 # include "os_solaris.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #ifdef TARGET_OS_FAMILY_windows
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 # include "os_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 elapsedTimer CMSAdaptiveSizePolicy::_concurrent_timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 elapsedTimer CMSAdaptiveSizePolicy::_STW_timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Defined if the granularity of the time measurements is potentially too large.
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #define CLOCK_GRANULARITY_TOO_LARGE
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 CMSAdaptiveSizePolicy::CMSAdaptiveSizePolicy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
48 size_t init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
49 double max_gc_minor_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 double max_gc_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
51 uint gc_cost_ratio) :
a61af66fc99e Initial load
duke
parents:
diff changeset
52 AdaptiveSizePolicy(init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
53 init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
54 init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
55 max_gc_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
56 gc_cost_ratio) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 clear_internal_time_intervals();
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _processor_count = os::active_processor_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
61
1284
5f1f51edaff6 6928081: G1: rename parameters common with CMS
jmasa
parents: 0
diff changeset
62 if (CMSConcurrentMTEnabled && (ConcGCThreads > 1)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 assert(_processor_count > 0, "Processor count is suspect");
1284
5f1f51edaff6 6928081: G1: rename parameters common with CMS
jmasa
parents: 0
diff changeset
64 _concurrent_processor_count = MIN2((uint) ConcGCThreads,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 (uint) _processor_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _concurrent_processor_count = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _avg_concurrent_time = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _avg_concurrent_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _avg_concurrent_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _avg_initial_pause = new AdaptivePaddedAverage(AdaptiveTimeWeight,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 PausePadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _avg_remark_pause = new AdaptivePaddedAverage(AdaptiveTimeWeight,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 PausePadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _avg_cms_STW_time = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _avg_cms_STW_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _avg_cms_free = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 _avg_cms_free_at_sweep = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _avg_cms_promo = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Mark-sweep-compact
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _avg_msc_pause = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _avg_msc_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _avg_msc_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Mark-sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
92 _avg_ms_pause = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 _avg_ms_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _avg_ms_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Variables that estimate pause times as a function of generation
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // size.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _remark_pause_old_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
99 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _initial_pause_old_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
101 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _remark_pause_young_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
103 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _initial_pause_young_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
105 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Alignment comes from that used in ReservedSpace.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _generation_alignment = os::vm_allocation_granularity();
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Start the concurrent timer here so that the first
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // concurrent_phases_begin() measures a finite mutator
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // time. A finite mutator time is used to determine
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // if a concurrent collection has been started. If this
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // proves to be a problem, use some explicit flag to
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // signal that a concurrent collection has been started.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 double CMSAdaptiveSizePolicy::concurrent_processor_fraction() {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // For now assume no other daemon threads are taking alway
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // cpu's from the application.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return ((double) _concurrent_processor_count / (double) _processor_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 double CMSAdaptiveSizePolicy::concurrent_collection_cost(
a61af66fc99e Initial load
duke
parents:
diff changeset
127 double interval_in_seconds) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // When the precleaning and sweeping phases use multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // threads, change one_processor_fraction to
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // concurrent_processor_fraction().
a61af66fc99e Initial load
duke
parents:
diff changeset
131 double one_processor_fraction = 1.0 / ((double) processor_count());
a61af66fc99e Initial load
duke
parents:
diff changeset
132 double concurrent_cost =
a61af66fc99e Initial load
duke
parents:
diff changeset
133 collection_cost(_latest_cms_concurrent_marking_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
134 interval_in_seconds) * concurrent_processor_fraction() +
a61af66fc99e Initial load
duke
parents:
diff changeset
135 collection_cost(_latest_cms_concurrent_precleaning_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 interval_in_seconds) * one_processor_fraction +
a61af66fc99e Initial load
duke
parents:
diff changeset
137 collection_cost(_latest_cms_concurrent_sweeping_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
138 interval_in_seconds) * one_processor_fraction;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
141 "\nCMSAdaptiveSizePolicy::scaled_concurrent_collection_cost(%f) "
a61af66fc99e Initial load
duke
parents:
diff changeset
142 "_latest_cms_concurrent_marking_cost %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
143 "_latest_cms_concurrent_precleaning_cost %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "_latest_cms_concurrent_sweeping_cost %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
145 "concurrent_processor_fraction %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
146 "concurrent_cost %f ",
a61af66fc99e Initial load
duke
parents:
diff changeset
147 interval_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
148 collection_cost(_latest_cms_concurrent_marking_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
149 interval_in_seconds),
a61af66fc99e Initial load
duke
parents:
diff changeset
150 collection_cost(_latest_cms_concurrent_precleaning_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
151 interval_in_seconds),
a61af66fc99e Initial load
duke
parents:
diff changeset
152 collection_cost(_latest_cms_concurrent_sweeping_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
153 interval_in_seconds),
a61af66fc99e Initial load
duke
parents:
diff changeset
154 concurrent_processor_fraction(),
a61af66fc99e Initial load
duke
parents:
diff changeset
155 concurrent_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return concurrent_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 double CMSAdaptiveSizePolicy::concurrent_collection_time() {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 double latest_cms_sum_concurrent_phases_time_secs =
a61af66fc99e Initial load
duke
parents:
diff changeset
162 _latest_cms_concurrent_marking_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
163 _latest_cms_concurrent_precleaning_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
164 _latest_cms_concurrent_sweeping_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return latest_cms_sum_concurrent_phases_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 double CMSAdaptiveSizePolicy::scaled_concurrent_collection_time() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // When the precleaning and sweeping phases use multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // threads, change one_processor_fraction to
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // concurrent_processor_fraction().
a61af66fc99e Initial load
duke
parents:
diff changeset
172 double one_processor_fraction = 1.0 / ((double) processor_count());
a61af66fc99e Initial load
duke
parents:
diff changeset
173 double latest_cms_sum_concurrent_phases_time_secs =
a61af66fc99e Initial load
duke
parents:
diff changeset
174 _latest_cms_concurrent_marking_time_secs * concurrent_processor_fraction() +
a61af66fc99e Initial load
duke
parents:
diff changeset
175 _latest_cms_concurrent_precleaning_time_secs * one_processor_fraction +
a61af66fc99e Initial load
duke
parents:
diff changeset
176 _latest_cms_concurrent_sweeping_time_secs * one_processor_fraction ;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
179 "\nCMSAdaptiveSizePolicy::scaled_concurrent_collection_time "
a61af66fc99e Initial load
duke
parents:
diff changeset
180 "_latest_cms_concurrent_marking_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
181 "_latest_cms_concurrent_precleaning_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
182 "_latest_cms_concurrent_sweeping_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
183 "concurrent_processor_fraction %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
184 "latest_cms_sum_concurrent_phases_time_secs %f ",
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _latest_cms_concurrent_marking_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
186 _latest_cms_concurrent_precleaning_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
187 _latest_cms_concurrent_sweeping_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
188 concurrent_processor_fraction(),
a61af66fc99e Initial load
duke
parents:
diff changeset
189 latest_cms_sum_concurrent_phases_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return latest_cms_sum_concurrent_phases_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 void CMSAdaptiveSizePolicy::update_minor_pause_old_estimator(
a61af66fc99e Initial load
duke
parents:
diff changeset
195 double minor_pause_in_ms) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Get the equivalent of the free space
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // that is available for promotions in the CMS generation
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // and use that to update _minor_pause_old_estimator
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // Don't implement this until it is needed. A warning is
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // printed if _minor_pause_old_estimator is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 void CMSAdaptiveSizePolicy::concurrent_marking_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 gclog_or_tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 gclog_or_tty->print(": concurrent_marking_begin ");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Update the interval time
a61af66fc99e Initial load
duke
parents:
diff changeset
211 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 _latest_cms_collection_end_to_collection_start_secs = _concurrent_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_marking_begin: "
a61af66fc99e Initial load
duke
parents:
diff changeset
215 "mutator time %f", _latest_cms_collection_end_to_collection_start_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 _concurrent_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 void CMSAdaptiveSizePolicy::concurrent_marking_end() {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
224 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_marking_end()");
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
228 _latest_cms_concurrent_marking_time_secs = _concurrent_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_marking_end"
a61af66fc99e Initial load
duke
parents:
diff changeset
232 ":concurrent marking time (s) %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
233 _latest_cms_concurrent_marking_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 void CMSAdaptiveSizePolicy::concurrent_precleaning_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
241 "CMSAdaptiveSizePolicy::concurrent_precleaning_begin()");
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 _concurrent_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
244 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 void CMSAdaptiveSizePolicy::concurrent_precleaning_end() {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_precleaning_end()");
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // May be set again by a second call during the same collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
256 _latest_cms_concurrent_precleaning_time_secs = _concurrent_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_precleaning_end"
a61af66fc99e Initial load
duke
parents:
diff changeset
260 ":concurrent precleaning time (s) %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
261 _latest_cms_concurrent_precleaning_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 void CMSAdaptiveSizePolicy::concurrent_sweeping_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
269 "CMSAdaptiveSizePolicy::concurrent_sweeping_begin()");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 _concurrent_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
272 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 void CMSAdaptiveSizePolicy::concurrent_sweeping_end() {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
279 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_sweeping_end()");
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
283 _latest_cms_concurrent_sweeping_time_secs = _concurrent_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 gclog_or_tty->print_cr("\n CMSAdaptiveSizePolicy::concurrent_sweeping_end"
a61af66fc99e Initial load
duke
parents:
diff changeset
287 ":concurrent sweeping time (s) %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
288 _latest_cms_concurrent_sweeping_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 void CMSAdaptiveSizePolicy::concurrent_phases_end(GCCause::Cause gc_cause,
a61af66fc99e Initial load
duke
parents:
diff changeset
293 size_t cur_eden,
a61af66fc99e Initial load
duke
parents:
diff changeset
294 size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 gclog_or_tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
297 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
298 gclog_or_tty->print(": concurrent_phases_end ");
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // Update the concurrent timer
a61af66fc99e Initial load
duke
parents:
diff changeset
302 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
305 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 avg_cms_free()->sample(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 double latest_cms_sum_concurrent_phases_time_secs =
a61af66fc99e Initial load
duke
parents:
diff changeset
309 concurrent_collection_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 _avg_concurrent_time->sample(latest_cms_sum_concurrent_phases_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Cost of collection (unit-less)
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // Total interval for collection. May not be valid. Tests
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // below determine whether to use this.
a61af66fc99e Initial load
duke
parents:
diff changeset
317 //
a61af66fc99e Initial load
duke
parents:
diff changeset
318 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 gclog_or_tty->print_cr("\nCMSAdaptiveSizePolicy::concurrent_phases_end \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
320 "_latest_cms_reset_end_to_initial_mark_start_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
321 "_latest_cms_initial_mark_start_to_end_time_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
322 "_latest_cms_remark_start_to_end_time_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
323 "_latest_cms_concurrent_marking_time_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
324 "_latest_cms_concurrent_precleaning_time_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
325 "_latest_cms_concurrent_sweeping_time_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
326 "latest_cms_sum_concurrent_phases_time_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
327 "_latest_cms_collection_end_to_collection_start_secs %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
328 "concurrent_processor_fraction %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
329 _latest_cms_reset_end_to_initial_mark_start_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
330 _latest_cms_initial_mark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
331 _latest_cms_remark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
332 _latest_cms_concurrent_marking_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
333 _latest_cms_concurrent_precleaning_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
334 _latest_cms_concurrent_sweeping_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
335 latest_cms_sum_concurrent_phases_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
336 _latest_cms_collection_end_to_collection_start_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
337 concurrent_processor_fraction());
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 double interval_in_seconds =
a61af66fc99e Initial load
duke
parents:
diff changeset
340 _latest_cms_initial_mark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
341 _latest_cms_remark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
342 latest_cms_sum_concurrent_phases_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
343 _latest_cms_collection_end_to_collection_start_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 assert(interval_in_seconds >= 0.0,
a61af66fc99e Initial load
duke
parents:
diff changeset
345 "Bad interval between cms collections");
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // Sample for performance counter
a61af66fc99e Initial load
duke
parents:
diff changeset
348 avg_concurrent_interval()->sample(interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // STW costs (initial and remark pauses)
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Cost of collection (unit-less)
a61af66fc99e Initial load
duke
parents:
diff changeset
352 assert(_latest_cms_initial_mark_start_to_end_time_secs >= 0.0,
a61af66fc99e Initial load
duke
parents:
diff changeset
353 "Bad initial mark pause");
a61af66fc99e Initial load
duke
parents:
diff changeset
354 assert(_latest_cms_remark_start_to_end_time_secs >= 0.0,
a61af66fc99e Initial load
duke
parents:
diff changeset
355 "Bad remark pause");
a61af66fc99e Initial load
duke
parents:
diff changeset
356 double STW_time_in_seconds =
a61af66fc99e Initial load
duke
parents:
diff changeset
357 _latest_cms_initial_mark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
358 _latest_cms_remark_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
359 double STW_collection_cost = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 if (interval_in_seconds > 0.0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // cost for the STW phases of the concurrent collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
362 STW_collection_cost = STW_time_in_seconds / interval_in_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 avg_cms_STW_gc_cost()->sample(STW_collection_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 gclog_or_tty->print("cmsAdaptiveSizePolicy::STW_collection_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
367 "STW gc cost: %f average: %f", STW_collection_cost,
a61af66fc99e Initial load
duke
parents:
diff changeset
368 avg_cms_STW_gc_cost()->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
369 gclog_or_tty->print_cr(" STW pause: %f (ms) STW period %f (ms)",
a61af66fc99e Initial load
duke
parents:
diff changeset
370 (double) STW_time_in_seconds * MILLIUNITS,
a61af66fc99e Initial load
duke
parents:
diff changeset
371 (double) interval_in_seconds * MILLIUNITS);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 double concurrent_cost = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
375 if (latest_cms_sum_concurrent_phases_time_secs > 0.0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 concurrent_cost = concurrent_collection_cost(interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 avg_concurrent_gc_cost()->sample(concurrent_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // Average this ms cost into all the other types gc costs
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 gclog_or_tty->print("cmsAdaptiveSizePolicy::concurrent_phases_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
383 "concurrent gc cost: %f average: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
384 concurrent_cost,
a61af66fc99e Initial load
duke
parents:
diff changeset
385 _avg_concurrent_gc_cost->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
386 gclog_or_tty->print_cr(" concurrent time: %f (ms) cms period %f (ms)"
a61af66fc99e Initial load
duke
parents:
diff changeset
387 " processor fraction: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
388 latest_cms_sum_concurrent_phases_time_secs * MILLIUNITS,
a61af66fc99e Initial load
duke
parents:
diff changeset
389 interval_in_seconds * MILLIUNITS,
a61af66fc99e Initial load
duke
parents:
diff changeset
390 concurrent_processor_fraction());
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
393 double total_collection_cost = STW_collection_cost + concurrent_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 avg_major_gc_cost()->sample(total_collection_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // Gather information for estimating future behavior
a61af66fc99e Initial load
duke
parents:
diff changeset
397 double initial_pause_in_ms = _latest_cms_initial_mark_start_to_end_time_secs * MILLIUNITS;
a61af66fc99e Initial load
duke
parents:
diff changeset
398 double remark_pause_in_ms = _latest_cms_remark_start_to_end_time_secs * MILLIUNITS;
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 double cur_promo_size_in_mbytes = ((double)cur_promo)/((double)M);
a61af66fc99e Initial load
duke
parents:
diff changeset
401 initial_pause_old_estimator()->update(cur_promo_size_in_mbytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
402 initial_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 remark_pause_old_estimator()->update(cur_promo_size_in_mbytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
404 remark_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
405 major_collection_estimator()->update(cur_promo_size_in_mbytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
406 total_collection_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // This estimate uses the average eden size. It could also
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // have used the latest eden size. Which is better?
a61af66fc99e Initial load
duke
parents:
diff changeset
410 double cur_eden_size_in_mbytes = ((double)cur_eden)/((double) M);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 initial_pause_young_estimator()->update(cur_eden_size_in_mbytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
412 initial_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
413 remark_pause_young_estimator()->update(cur_eden_size_in_mbytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
414 remark_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417 clear_internal_time_intervals();
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 set_first_after_collection();
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // The concurrent phases keeps track of it's own mutator interval
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // with this timer. This allows the stop-the-world phase to
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // be included in the mutator time so that the stop-the-world time
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // is not double counted. Reset and start it.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 _concurrent_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
426 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // The mutator time between STW phases does not include the
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // concurrent collection time.
a61af66fc99e Initial load
duke
parents:
diff changeset
430 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 void CMSAdaptiveSizePolicy::checkpoint_roots_initial_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // Update the interval time
a61af66fc99e Initial load
duke
parents:
diff changeset
436 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
437 _latest_cms_reset_end_to_initial_mark_start_secs = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // Reset for the initial mark
a61af66fc99e Initial load
duke
parents:
diff changeset
439 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
440 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
442
a61af66fc99e Initial load
duke
parents:
diff changeset
443 void CMSAdaptiveSizePolicy::checkpoint_roots_initial_end(
a61af66fc99e Initial load
duke
parents:
diff changeset
444 GCCause::Cause gc_cause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
445 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
448 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 _latest_cms_initial_mark_start_to_end_time_secs = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
450 avg_initial_pause()->sample(_latest_cms_initial_mark_start_to_end_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 gclog_or_tty->print(
a61af66fc99e Initial load
duke
parents:
diff changeset
454 "cmsAdaptiveSizePolicy::checkpoint_roots_initial_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
455 "initial pause: %f ", _latest_cms_initial_mark_start_to_end_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458
a61af66fc99e Initial load
duke
parents:
diff changeset
459 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
460 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 void CMSAdaptiveSizePolicy::checkpoint_roots_final_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
465 _latest_cms_initial_mark_end_to_remark_start_secs = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // Start accumumlating time for the remark in the STW timer.
a61af66fc99e Initial load
duke
parents:
diff changeset
467 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
468 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
470
a61af66fc99e Initial load
duke
parents:
diff changeset
471 void CMSAdaptiveSizePolicy::checkpoint_roots_final_end(
a61af66fc99e Initial load
duke
parents:
diff changeset
472 GCCause::Cause gc_cause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
474 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
475 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // Total initial mark pause + remark pause.
a61af66fc99e Initial load
duke
parents:
diff changeset
477 _latest_cms_remark_start_to_end_time_secs = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
478 double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
479 _latest_cms_remark_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
480 double STW_time_in_ms = STW_time_in_seconds * MILLIUNITS;
a61af66fc99e Initial load
duke
parents:
diff changeset
481
a61af66fc99e Initial load
duke
parents:
diff changeset
482 avg_remark_pause()->sample(_latest_cms_remark_start_to_end_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 // Sample total for initial mark + remark
a61af66fc99e Initial load
duke
parents:
diff changeset
485 avg_cms_STW_time()->sample(STW_time_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 gclog_or_tty->print("cmsAdaptiveSizePolicy::checkpoint_roots_final_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
489 "remark pause: %f", _latest_cms_remark_start_to_end_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // Don't start the STW times here because the concurrent
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // sweep and reset has not happened.
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // Keep the old comment above in case I don't understand
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // what is going on but now
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // Start the STW timer because it is used by ms_collection_begin()
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // and ms_collection_end() to get the sweep time if a MS is being
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // done in the foreground.
a61af66fc99e Initial load
duke
parents:
diff changeset
500 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
501 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 void CMSAdaptiveSizePolicy::msc_collection_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
505 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
506 gclog_or_tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
507 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
508 gclog_or_tty->print(": msc_collection_begin ");
a61af66fc99e Initial load
duke
parents:
diff changeset
509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
510 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 _latest_cms_msc_end_to_msc_start_time_secs = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
512 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::msc_collection_begin: "
a61af66fc99e Initial load
duke
parents:
diff changeset
514 "mutator time %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
515 _latest_cms_msc_end_to_msc_start_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
516 }
a61af66fc99e Initial load
duke
parents:
diff changeset
517 avg_msc_interval()->sample(_latest_cms_msc_end_to_msc_start_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
518 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
519 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521
a61af66fc99e Initial load
duke
parents:
diff changeset
522 void CMSAdaptiveSizePolicy::msc_collection_end(GCCause::Cause gc_cause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
523 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
524 gclog_or_tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
525 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
526 gclog_or_tty->print(": msc_collection_end ");
a61af66fc99e Initial load
duke
parents:
diff changeset
527 }
a61af66fc99e Initial load
duke
parents:
diff changeset
528 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
529 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
530 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 double msc_pause_in_seconds = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
532 if ((_latest_cms_msc_end_to_msc_start_time_secs > 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
533 (msc_pause_in_seconds > 0.0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 avg_msc_pause()->sample(msc_pause_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 double mutator_time_in_seconds = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 if (_latest_cms_collection_end_to_collection_start_secs == 0.0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // This assertion may fail because of time stamp gradularity.
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // Comment it out and investiage it at a later time. The large
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // time stamp granularity occurs on some older linux systems.
a61af66fc99e Initial load
duke
parents:
diff changeset
540 #ifndef CLOCK_GRANULARITY_TOO_LARGE
a61af66fc99e Initial load
duke
parents:
diff changeset
541 assert((_latest_cms_concurrent_marking_time_secs == 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
542 (_latest_cms_concurrent_precleaning_time_secs == 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
543 (_latest_cms_concurrent_sweeping_time_secs == 0.0),
a61af66fc99e Initial load
duke
parents:
diff changeset
544 "There should not be any concurrent time");
a61af66fc99e Initial load
duke
parents:
diff changeset
545 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // A concurrent collection did not start. Mutator time
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // between collections comes from the STW MSC timer.
a61af66fc99e Initial load
duke
parents:
diff changeset
548 mutator_time_in_seconds = _latest_cms_msc_end_to_msc_start_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
549 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
550 // The concurrent collection did start so count the mutator
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // time to the start of the concurrent collection. In this
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // case the _latest_cms_msc_end_to_msc_start_time_secs measures
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // the time between the initial mark or remark and the
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // start of the MSC. That has no real meaning.
a61af66fc99e Initial load
duke
parents:
diff changeset
555 mutator_time_in_seconds = _latest_cms_collection_end_to_collection_start_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 double latest_cms_sum_concurrent_phases_time_secs =
a61af66fc99e Initial load
duke
parents:
diff changeset
559 concurrent_collection_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
560 double interval_in_seconds =
a61af66fc99e Initial load
duke
parents:
diff changeset
561 mutator_time_in_seconds +
a61af66fc99e Initial load
duke
parents:
diff changeset
562 _latest_cms_initial_mark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
563 _latest_cms_remark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
564 latest_cms_sum_concurrent_phases_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
565 msc_pause_in_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
568 gclog_or_tty->print_cr(" interval_in_seconds %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
569 " mutator_time_in_seconds %f \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
570 " _latest_cms_initial_mark_start_to_end_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
571 " _latest_cms_remark_start_to_end_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
572 " latest_cms_sum_concurrent_phases_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
573 " msc_pause_in_seconds %f\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
574 interval_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
575 mutator_time_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
576 _latest_cms_initial_mark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
577 _latest_cms_remark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
578 latest_cms_sum_concurrent_phases_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
579 msc_pause_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // The concurrent cost is wasted cost but it should be
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // included.
a61af66fc99e Initial load
duke
parents:
diff changeset
584 double concurrent_cost = concurrent_collection_cost(interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // Initial mark and remark, also wasted.
a61af66fc99e Initial load
duke
parents:
diff changeset
587 double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
588 _latest_cms_remark_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
589 double STW_collection_cost =
a61af66fc99e Initial load
duke
parents:
diff changeset
590 collection_cost(STW_time_in_seconds, interval_in_seconds) +
a61af66fc99e Initial load
duke
parents:
diff changeset
591 concurrent_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
592
a61af66fc99e Initial load
duke
parents:
diff changeset
593 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
594 gclog_or_tty->print_cr(" msc_collection_end:\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
595 "_latest_cms_collection_end_to_collection_start_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
596 "_latest_cms_msc_end_to_msc_start_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
597 "_latest_cms_initial_mark_start_to_end_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
598 "_latest_cms_remark_start_to_end_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
599 "latest_cms_sum_concurrent_phases_time_secs %f\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
600 _latest_cms_collection_end_to_collection_start_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
601 _latest_cms_msc_end_to_msc_start_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
602 _latest_cms_initial_mark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
603 _latest_cms_remark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
604 latest_cms_sum_concurrent_phases_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 gclog_or_tty->print_cr(" msc_collection_end: \n"
a61af66fc99e Initial load
duke
parents:
diff changeset
607 "latest_cms_sum_concurrent_phases_time_secs %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
608 "STW_time_in_seconds %f\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
609 "msc_pause_in_seconds %f\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
610 latest_cms_sum_concurrent_phases_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
611 STW_time_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
612 msc_pause_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615 double cost = concurrent_cost + STW_collection_cost +
a61af66fc99e Initial load
duke
parents:
diff changeset
616 collection_cost(msc_pause_in_seconds, interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
617
a61af66fc99e Initial load
duke
parents:
diff changeset
618 _avg_msc_gc_cost->sample(cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620 // Average this ms cost into all the other types gc costs
a61af66fc99e Initial load
duke
parents:
diff changeset
621 avg_major_gc_cost()->sample(cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // Sample for performance counter
a61af66fc99e Initial load
duke
parents:
diff changeset
624 _avg_msc_interval->sample(interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
625 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
626 gclog_or_tty->print("cmsAdaptiveSizePolicy::msc_collection_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
627 "MSC gc cost: %f average: %f", cost,
a61af66fc99e Initial load
duke
parents:
diff changeset
628 _avg_msc_gc_cost->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
629
a61af66fc99e Initial load
duke
parents:
diff changeset
630 double msc_pause_in_ms = msc_pause_in_seconds * MILLIUNITS;
a61af66fc99e Initial load
duke
parents:
diff changeset
631 gclog_or_tty->print_cr(" MSC pause: %f (ms) MSC period %f (ms)",
a61af66fc99e Initial load
duke
parents:
diff changeset
632 msc_pause_in_ms, (double) interval_in_seconds * MILLIUNITS);
a61af66fc99e Initial load
duke
parents:
diff changeset
633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
634 }
a61af66fc99e Initial load
duke
parents:
diff changeset
635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
636
a61af66fc99e Initial load
duke
parents:
diff changeset
637 clear_internal_time_intervals();
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // Can this call be put into the epilogue?
a61af66fc99e Initial load
duke
parents:
diff changeset
640 set_first_after_collection();
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // The concurrent phases keeps track of it's own mutator interval
a61af66fc99e Initial load
duke
parents:
diff changeset
643 // with this timer. This allows the stop-the-world phase to
a61af66fc99e Initial load
duke
parents:
diff changeset
644 // be included in the mutator time so that the stop-the-world time
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // is not double counted. Reset and start it.
a61af66fc99e Initial load
duke
parents:
diff changeset
646 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
647 _concurrent_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
648 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
649
a61af66fc99e Initial load
duke
parents:
diff changeset
650 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
651 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
653
a61af66fc99e Initial load
duke
parents:
diff changeset
654 void CMSAdaptiveSizePolicy::ms_collection_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
655 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 gclog_or_tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
657 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
658 gclog_or_tty->print(": ms_collection_begin ");
a61af66fc99e Initial load
duke
parents:
diff changeset
659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
660 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
661 _latest_cms_ms_end_to_ms_start = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
662 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::ms_collection_begin: "
a61af66fc99e Initial load
duke
parents:
diff changeset
664 "mutator time %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
665 _latest_cms_ms_end_to_ms_start);
a61af66fc99e Initial load
duke
parents:
diff changeset
666 }
a61af66fc99e Initial load
duke
parents:
diff changeset
667 avg_ms_interval()->sample(_STW_timer.seconds());
a61af66fc99e Initial load
duke
parents:
diff changeset
668 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
669 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 void CMSAdaptiveSizePolicy::ms_collection_end(GCCause::Cause gc_cause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
673 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 gclog_or_tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
675 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
676 gclog_or_tty->print(": ms_collection_end ");
a61af66fc99e Initial load
duke
parents:
diff changeset
677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
678 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
679 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
680 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
681 // The MS collection is a foreground collection that does all
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // the parts of a mostly concurrent collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
683 //
a61af66fc99e Initial load
duke
parents:
diff changeset
684 // For this collection include the cost of the
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // initial mark
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // remark
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // all concurrent time (scaled down by the
a61af66fc99e Initial load
duke
parents:
diff changeset
688 // concurrent_processor_fraction). Some
a61af66fc99e Initial load
duke
parents:
diff changeset
689 // may be zero if the baton was passed before
a61af66fc99e Initial load
duke
parents:
diff changeset
690 // it was reached.
a61af66fc99e Initial load
duke
parents:
diff changeset
691 // concurrent marking
a61af66fc99e Initial load
duke
parents:
diff changeset
692 // sweeping
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // resetting
a61af66fc99e Initial load
duke
parents:
diff changeset
694 // STW after baton was passed (STW_in_foreground_in_seconds)
a61af66fc99e Initial load
duke
parents:
diff changeset
695 double STW_in_foreground_in_seconds = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
696
a61af66fc99e Initial load
duke
parents:
diff changeset
697 double latest_cms_sum_concurrent_phases_time_secs =
a61af66fc99e Initial load
duke
parents:
diff changeset
698 concurrent_collection_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
699 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
700 gclog_or_tty->print_cr("\nCMSAdaptiveSizePolicy::ms_collecton_end "
a61af66fc99e Initial load
duke
parents:
diff changeset
701 "STW_in_foreground_in_seconds %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
702 "_latest_cms_initial_mark_start_to_end_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
703 "_latest_cms_remark_start_to_end_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
704 "latest_cms_sum_concurrent_phases_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
705 "_latest_cms_ms_marking_start_to_end_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
706 "_latest_cms_ms_end_to_ms_start %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
707 STW_in_foreground_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
708 _latest_cms_initial_mark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
709 _latest_cms_remark_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
710 latest_cms_sum_concurrent_phases_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
711 _latest_cms_ms_marking_start_to_end_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
712 _latest_cms_ms_end_to_ms_start);
a61af66fc99e Initial load
duke
parents:
diff changeset
713 }
a61af66fc99e Initial load
duke
parents:
diff changeset
714
a61af66fc99e Initial load
duke
parents:
diff changeset
715 double STW_marking_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
716 _latest_cms_remark_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
717 #ifndef CLOCK_GRANULARITY_TOO_LARGE
a61af66fc99e Initial load
duke
parents:
diff changeset
718 assert(_latest_cms_ms_marking_start_to_end_time_secs == 0.0 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
719 latest_cms_sum_concurrent_phases_time_secs == 0.0,
a61af66fc99e Initial load
duke
parents:
diff changeset
720 "marking done twice?");
a61af66fc99e Initial load
duke
parents:
diff changeset
721 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
722 double ms_time_in_seconds = STW_marking_in_seconds +
a61af66fc99e Initial load
duke
parents:
diff changeset
723 STW_in_foreground_in_seconds +
a61af66fc99e Initial load
duke
parents:
diff changeset
724 _latest_cms_ms_marking_start_to_end_time_secs +
a61af66fc99e Initial load
duke
parents:
diff changeset
725 scaled_concurrent_collection_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
726 avg_ms_pause()->sample(ms_time_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
727 // Use the STW costs from the initial mark and remark plus
a61af66fc99e Initial load
duke
parents:
diff changeset
728 // the cost of the concurrent phase to calculate a
a61af66fc99e Initial load
duke
parents:
diff changeset
729 // collection cost.
a61af66fc99e Initial load
duke
parents:
diff changeset
730 double cost = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
731 if ((_latest_cms_ms_end_to_ms_start > 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
732 (ms_time_in_seconds > 0.0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
733 double interval_in_seconds =
a61af66fc99e Initial load
duke
parents:
diff changeset
734 _latest_cms_ms_end_to_ms_start + ms_time_in_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
735
a61af66fc99e Initial load
duke
parents:
diff changeset
736 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
737 gclog_or_tty->print_cr("\n ms_time_in_seconds %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
738 "latest_cms_sum_concurrent_phases_time_secs %f "
a61af66fc99e Initial load
duke
parents:
diff changeset
739 "interval_in_seconds %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
740 ms_time_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
741 latest_cms_sum_concurrent_phases_time_secs,
a61af66fc99e Initial load
duke
parents:
diff changeset
742 interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
743 }
a61af66fc99e Initial load
duke
parents:
diff changeset
744
a61af66fc99e Initial load
duke
parents:
diff changeset
745 cost = collection_cost(ms_time_in_seconds, interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
746
a61af66fc99e Initial load
duke
parents:
diff changeset
747 _avg_ms_gc_cost->sample(cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
748 // Average this ms cost into all the other types gc costs
a61af66fc99e Initial load
duke
parents:
diff changeset
749 avg_major_gc_cost()->sample(cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
750
a61af66fc99e Initial load
duke
parents:
diff changeset
751 // Sample for performance counter
a61af66fc99e Initial load
duke
parents:
diff changeset
752 _avg_ms_interval->sample(interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
753 }
a61af66fc99e Initial load
duke
parents:
diff changeset
754 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
755 gclog_or_tty->print("cmsAdaptiveSizePolicy::ms_collection_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
756 "MS gc cost: %f average: %f", cost, _avg_ms_gc_cost->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
757
a61af66fc99e Initial load
duke
parents:
diff changeset
758 double ms_time_in_ms = ms_time_in_seconds * MILLIUNITS;
a61af66fc99e Initial load
duke
parents:
diff changeset
759 gclog_or_tty->print_cr(" MS pause: %f (ms) MS period %f (ms)",
a61af66fc99e Initial load
duke
parents:
diff changeset
760 ms_time_in_ms,
a61af66fc99e Initial load
duke
parents:
diff changeset
761 _latest_cms_ms_end_to_ms_start * MILLIUNITS);
a61af66fc99e Initial load
duke
parents:
diff changeset
762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
763 }
a61af66fc99e Initial load
duke
parents:
diff changeset
764
a61af66fc99e Initial load
duke
parents:
diff changeset
765 // Consider putting this code (here to end) into a
a61af66fc99e Initial load
duke
parents:
diff changeset
766 // method for convenience.
a61af66fc99e Initial load
duke
parents:
diff changeset
767 clear_internal_time_intervals();
a61af66fc99e Initial load
duke
parents:
diff changeset
768
a61af66fc99e Initial load
duke
parents:
diff changeset
769 set_first_after_collection();
a61af66fc99e Initial load
duke
parents:
diff changeset
770
a61af66fc99e Initial load
duke
parents:
diff changeset
771 // The concurrent phases keeps track of it's own mutator interval
a61af66fc99e Initial load
duke
parents:
diff changeset
772 // with this timer. This allows the stop-the-world phase to
a61af66fc99e Initial load
duke
parents:
diff changeset
773 // be included in the mutator time so that the stop-the-world time
a61af66fc99e Initial load
duke
parents:
diff changeset
774 // is not double counted. Reset and start it.
a61af66fc99e Initial load
duke
parents:
diff changeset
775 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
776 _concurrent_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
777 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
778
a61af66fc99e Initial load
duke
parents:
diff changeset
779 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
780 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
782
a61af66fc99e Initial load
duke
parents:
diff changeset
783 void CMSAdaptiveSizePolicy::clear_internal_time_intervals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
784 _latest_cms_reset_end_to_initial_mark_start_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
785 _latest_cms_initial_mark_end_to_remark_start_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
786 _latest_cms_collection_end_to_collection_start_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
787 _latest_cms_concurrent_marking_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
788 _latest_cms_concurrent_precleaning_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
789 _latest_cms_concurrent_sweeping_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
790 _latest_cms_msc_end_to_msc_start_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
791 _latest_cms_ms_end_to_ms_start = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
792 _latest_cms_remark_start_to_end_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
793 _latest_cms_initial_mark_start_to_end_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
794 _latest_cms_ms_marking_start_to_end_time_secs = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 void CMSAdaptiveSizePolicy::clear_generation_free_space_flags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
798 AdaptiveSizePolicy::clear_generation_free_space_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
799
a61af66fc99e Initial load
duke
parents:
diff changeset
800 set_change_young_gen_for_maj_pauses(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
802
a61af66fc99e Initial load
duke
parents:
diff changeset
803 void CMSAdaptiveSizePolicy::concurrent_phases_resume() {
a61af66fc99e Initial load
duke
parents:
diff changeset
804 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
805 gclog_or_tty->stamp();
a61af66fc99e Initial load
duke
parents:
diff changeset
806 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::concurrent_phases_resume()");
a61af66fc99e Initial load
duke
parents:
diff changeset
807 }
a61af66fc99e Initial load
duke
parents:
diff changeset
808 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 double CMSAdaptiveSizePolicy::time_since_major_gc() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
812 _concurrent_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
813 double time_since_cms_gc = _concurrent_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
814 _concurrent_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
815 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
816 double time_since_STW_gc = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
817 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
818
a61af66fc99e Initial load
duke
parents:
diff changeset
819 return MIN2(time_since_cms_gc, time_since_STW_gc);
a61af66fc99e Initial load
duke
parents:
diff changeset
820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
821
a61af66fc99e Initial load
duke
parents:
diff changeset
822 double CMSAdaptiveSizePolicy::major_gc_interval_average_for_decay() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
823 double cms_interval = _avg_concurrent_interval->average();
a61af66fc99e Initial load
duke
parents:
diff changeset
824 double msc_interval = _avg_msc_interval->average();
a61af66fc99e Initial load
duke
parents:
diff changeset
825 double ms_interval = _avg_ms_interval->average();
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 return MAX3(cms_interval, msc_interval, ms_interval);
a61af66fc99e Initial load
duke
parents:
diff changeset
828 }
a61af66fc99e Initial load
duke
parents:
diff changeset
829
a61af66fc99e Initial load
duke
parents:
diff changeset
830 double CMSAdaptiveSizePolicy::cms_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
831 return avg_major_gc_cost()->average();
a61af66fc99e Initial load
duke
parents:
diff changeset
832 }
a61af66fc99e Initial load
duke
parents:
diff changeset
833
a61af66fc99e Initial load
duke
parents:
diff changeset
834 void CMSAdaptiveSizePolicy::ms_collection_marking_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
835 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
836 // Start accumumlating time for the marking in the STW timer.
a61af66fc99e Initial load
duke
parents:
diff changeset
837 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
838 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
840
a61af66fc99e Initial load
duke
parents:
diff changeset
841 void CMSAdaptiveSizePolicy::ms_collection_marking_end(
a61af66fc99e Initial load
duke
parents:
diff changeset
842 GCCause::Cause gc_cause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
843 _STW_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
844 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
845 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
846 _latest_cms_ms_marking_start_to_end_time_secs = _STW_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
847 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
848 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::"
a61af66fc99e Initial load
duke
parents:
diff changeset
849 "msc_collection_marking_end: mutator time %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
850 _latest_cms_ms_marking_start_to_end_time_secs);
a61af66fc99e Initial load
duke
parents:
diff changeset
851 }
a61af66fc99e Initial load
duke
parents:
diff changeset
852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
853 _STW_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
854 _STW_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
856
a61af66fc99e Initial load
duke
parents:
diff changeset
857 double CMSAdaptiveSizePolicy::gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
858 double cms_gen_cost = cms_gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
859 double result = MIN2(1.0, minor_gc_cost() + cms_gen_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
860 assert(result >= 0.0, "Both minor and major costs are non-negative");
a61af66fc99e Initial load
duke
parents:
diff changeset
861 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
862 }
a61af66fc99e Initial load
duke
parents:
diff changeset
863
a61af66fc99e Initial load
duke
parents:
diff changeset
864 // Cost of collection (unit-less)
a61af66fc99e Initial load
duke
parents:
diff changeset
865 double CMSAdaptiveSizePolicy::collection_cost(double pause_in_seconds,
a61af66fc99e Initial load
duke
parents:
diff changeset
866 double interval_in_seconds) {
a61af66fc99e Initial load
duke
parents:
diff changeset
867 // Cost of collection (unit-less)
a61af66fc99e Initial load
duke
parents:
diff changeset
868 double cost = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
869 if ((interval_in_seconds > 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
870 (pause_in_seconds > 0.0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
871 cost =
a61af66fc99e Initial load
duke
parents:
diff changeset
872 pause_in_seconds / interval_in_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
873 }
a61af66fc99e Initial load
duke
parents:
diff changeset
874 return cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
876
a61af66fc99e Initial load
duke
parents:
diff changeset
877 size_t CMSAdaptiveSizePolicy::adjust_eden_for_pause_time(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
878 size_t change = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
879 size_t desired_eden = cur_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
880
a61af66fc99e Initial load
duke
parents:
diff changeset
881 // reduce eden size
a61af66fc99e Initial load
duke
parents:
diff changeset
882 change = eden_decrement_aligned_down(cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
883 desired_eden = cur_eden - change;
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
886 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
887 "CMSAdaptiveSizePolicy::adjust_eden_for_pause_time "
a61af66fc99e Initial load
duke
parents:
diff changeset
888 "adjusting eden for pause time. "
a61af66fc99e Initial load
duke
parents:
diff changeset
889 " starting eden size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
890 " reduced eden size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
891 " eden delta " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
892 cur_eden, desired_eden, change);
a61af66fc99e Initial load
duke
parents:
diff changeset
893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
894
a61af66fc99e Initial load
duke
parents:
diff changeset
895 return desired_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
896 }
a61af66fc99e Initial load
duke
parents:
diff changeset
897
a61af66fc99e Initial load
duke
parents:
diff changeset
898 size_t CMSAdaptiveSizePolicy::adjust_eden_for_throughput(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
899
a61af66fc99e Initial load
duke
parents:
diff changeset
900 size_t desired_eden = cur_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902 set_change_young_gen_for_throughput(increase_young_gen_for_througput_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
903
a61af66fc99e Initial load
duke
parents:
diff changeset
904 size_t change = eden_increment_aligned_up(cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
905 size_t scaled_change = scale_by_gen_gc_cost(change, minor_gc_cost());
a61af66fc99e Initial load
duke
parents:
diff changeset
906
a61af66fc99e Initial load
duke
parents:
diff changeset
907 if (cur_eden + scaled_change > cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
908 desired_eden = cur_eden + scaled_change;
a61af66fc99e Initial load
duke
parents:
diff changeset
909 }
a61af66fc99e Initial load
duke
parents:
diff changeset
910
a61af66fc99e Initial load
duke
parents:
diff changeset
911 _young_gen_change_for_minor_throughput++;
a61af66fc99e Initial load
duke
parents:
diff changeset
912
a61af66fc99e Initial load
duke
parents:
diff changeset
913 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
914 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
915 "CMSAdaptiveSizePolicy::adjust_eden_for_throughput "
a61af66fc99e Initial load
duke
parents:
diff changeset
916 "adjusting eden for throughput. "
a61af66fc99e Initial load
duke
parents:
diff changeset
917 " starting eden size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
918 " increased eden size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
919 " eden delta " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
920 cur_eden, desired_eden, scaled_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
922
a61af66fc99e Initial load
duke
parents:
diff changeset
923 return desired_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
924 }
a61af66fc99e Initial load
duke
parents:
diff changeset
925
a61af66fc99e Initial load
duke
parents:
diff changeset
926 size_t CMSAdaptiveSizePolicy::adjust_eden_for_footprint(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
927
a61af66fc99e Initial load
duke
parents:
diff changeset
928 set_decrease_for_footprint(decrease_young_gen_for_footprint_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
929
a61af66fc99e Initial load
duke
parents:
diff changeset
930 size_t change = eden_decrement(cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
931 size_t desired_eden_size = cur_eden - change;
a61af66fc99e Initial load
duke
parents:
diff changeset
932
a61af66fc99e Initial load
duke
parents:
diff changeset
933 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
934 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
935 "CMSAdaptiveSizePolicy::adjust_eden_for_footprint "
a61af66fc99e Initial load
duke
parents:
diff changeset
936 "adjusting eden for footprint. "
a61af66fc99e Initial load
duke
parents:
diff changeset
937 " starting eden size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
938 " reduced eden size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
939 " eden delta " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
940 cur_eden, desired_eden_size, change);
a61af66fc99e Initial load
duke
parents:
diff changeset
941 }
a61af66fc99e Initial load
duke
parents:
diff changeset
942 return desired_eden_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
944
a61af66fc99e Initial load
duke
parents:
diff changeset
945 // The eden and promo versions should be combined if possible.
a61af66fc99e Initial load
duke
parents:
diff changeset
946 // They are the same except that the sizes of the decrement
a61af66fc99e Initial load
duke
parents:
diff changeset
947 // and increment are different for eden and promo.
a61af66fc99e Initial load
duke
parents:
diff changeset
948 size_t CMSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
949 size_t delta = eden_decrement(cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
950 return align_size_down(delta, generation_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
951 }
a61af66fc99e Initial load
duke
parents:
diff changeset
952
a61af66fc99e Initial load
duke
parents:
diff changeset
953 size_t CMSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
954 size_t delta = eden_increment(cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
955 return align_size_up(delta, generation_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
957
a61af66fc99e Initial load
duke
parents:
diff changeset
958 size_t CMSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
959 size_t delta = promo_decrement(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
960 return align_size_down(delta, generation_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
961 }
a61af66fc99e Initial load
duke
parents:
diff changeset
962
a61af66fc99e Initial load
duke
parents:
diff changeset
963 size_t CMSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
964 size_t delta = promo_increment(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
965 return align_size_up(delta, generation_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
966 }
a61af66fc99e Initial load
duke
parents:
diff changeset
967
a61af66fc99e Initial load
duke
parents:
diff changeset
968
a61af66fc99e Initial load
duke
parents:
diff changeset
969 void CMSAdaptiveSizePolicy::compute_young_generation_free_space(size_t cur_eden,
a61af66fc99e Initial load
duke
parents:
diff changeset
970 size_t max_eden_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
971 {
a61af66fc99e Initial load
duke
parents:
diff changeset
972 size_t desired_eden_size = cur_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
973 size_t eden_limit = max_eden_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
974
a61af66fc99e Initial load
duke
parents:
diff changeset
975 // Printout input
a61af66fc99e Initial load
duke
parents:
diff changeset
976 if (PrintGC && PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
977 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
978 "CMSAdaptiveSizePolicy::compute_young_generation_free_space: "
a61af66fc99e Initial load
duke
parents:
diff changeset
979 "cur_eden " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
980 cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
981 }
a61af66fc99e Initial load
duke
parents:
diff changeset
982
a61af66fc99e Initial load
duke
parents:
diff changeset
983 // Used for diagnostics
a61af66fc99e Initial load
duke
parents:
diff changeset
984 clear_generation_free_space_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
985
a61af66fc99e Initial load
duke
parents:
diff changeset
986 if (_avg_minor_pause->padded_average() > gc_pause_goal_sec()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
987 if (minor_pause_young_estimator()->decrement_will_decrease()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
988 // If the minor pause is too long, shrink the young gen.
a61af66fc99e Initial load
duke
parents:
diff changeset
989 set_change_young_gen_for_min_pauses(
a61af66fc99e Initial load
duke
parents:
diff changeset
990 decrease_young_gen_for_min_pauses_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
991 desired_eden_size = adjust_eden_for_pause_time(desired_eden_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
992 }
a61af66fc99e Initial load
duke
parents:
diff changeset
993 } else if ((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
994 (avg_initial_pause()->padded_average() > gc_pause_goal_sec())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
995 // The remark or initial pauses are not meeting the goal. Should
a61af66fc99e Initial load
duke
parents:
diff changeset
996 // the generation be shrunk?
a61af66fc99e Initial load
duke
parents:
diff changeset
997 if (get_and_clear_first_after_collection() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
998 ((avg_remark_pause()->padded_average() > gc_pause_goal_sec() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
999 remark_pause_young_estimator()->decrement_will_decrease()) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 (avg_initial_pause()->padded_average() > gc_pause_goal_sec() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 initial_pause_young_estimator()->decrement_will_decrease()))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1002
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 set_change_young_gen_for_maj_pauses(
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 decrease_young_gen_for_maj_pauses_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1005
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 // If the remark or initial pause is too long and this is the
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 // first young gen collection after a cms collection, shrink
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 // the young gen.
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 desired_eden_size = adjust_eden_for_pause_time(desired_eden_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 // If not the first young gen collection after a cms collection,
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 // don't do anything. In this case an adjustment has already
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // been made and the results of the adjustment has not yet been
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 // measured.
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 } else if ((minor_gc_cost() >= 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 (adjusted_mutator_cost() < _throughput_goal)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 desired_eden_size = adjust_eden_for_throughput(desired_eden_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 desired_eden_size = adjust_eden_for_footprint(desired_eden_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1021
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 if (PrintGC && PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 "CMSAdaptiveSizePolicy::compute_young_generation_free_space limits:"
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 " desired_eden_size: " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 " old_eden_size: " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 desired_eden_size, cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1029
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 set_eden_size(desired_eden_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1032
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 size_t CMSAdaptiveSizePolicy::adjust_promo_for_pause_time(size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 size_t change = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 size_t desired_promo = cur_promo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 // Move this test up to caller like the adjust_eden_for_pause_time()
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 // call.
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 if ((AdaptiveSizePausePolicy == 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 ((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 (avg_initial_pause()->padded_average() > gc_pause_goal_sec()))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 change = promo_decrement_aligned_down(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 desired_promo = cur_promo - change;
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 } else if ((AdaptiveSizePausePolicy > 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 (((avg_remark_pause()->padded_average() > gc_pause_goal_sec()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 remark_pause_old_estimator()->decrement_will_decrease()) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 ((avg_initial_pause()->padded_average() > gc_pause_goal_sec()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 initial_pause_old_estimator()->decrement_will_decrease()))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 set_change_old_gen_for_maj_pauses(decrease_old_gen_for_maj_pauses_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 change = promo_decrement_aligned_down(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 desired_promo = cur_promo - change;
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1053
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 if ((change != 0) &&PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 "CMSAdaptiveSizePolicy::adjust_promo_for_pause_time "
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 "adjusting promo for pause time. "
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 " starting promo size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 " reduced promo size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 " promo delta " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 cur_promo, desired_promo, change);
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1063
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 return desired_promo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 // Try to share this with PS.
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 size_t CMSAdaptiveSizePolicy::scale_by_gen_gc_cost(size_t base_change,
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 double gen_gc_cost) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1070
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 // Calculate the change to use for the tenured gen.
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 size_t scaled_change = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 // Can the increment to the generation be scaled?
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 if (gc_cost() >= 0.0 && gen_gc_cost >= 0.0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 double scale_by_ratio = gen_gc_cost / gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 scaled_change =
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 (size_t) (scale_by_ratio * (double) base_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 "Scaled tenured increment: " SIZE_FORMAT " by %f down to "
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 base_change, scale_by_ratio, scaled_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 } else if (gen_gc_cost >= 0.0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 // Scaling is not going to work. If the major gc time is the
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 // larger than the other GC costs, give it a full increment.
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 if (gen_gc_cost >= (gc_cost() - gen_gc_cost)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 scaled_change = base_change;
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 // Don't expect to get here but it's ok if it does
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 // in the product build since the delta will be 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 // and nothing will change.
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 assert(false, "Unexpected value for gc costs");
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1096
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 return scaled_change;
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1099
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 size_t CMSAdaptiveSizePolicy::adjust_promo_for_throughput(size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1101
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 size_t desired_promo = cur_promo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1103
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 set_change_old_gen_for_throughput(increase_old_gen_for_throughput_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1105
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 size_t change = promo_increment_aligned_up(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 size_t scaled_change = scale_by_gen_gc_cost(change, major_gc_cost());
a61af66fc99e Initial load
duke
parents:
diff changeset
1108
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 if (cur_promo + scaled_change > cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 desired_promo = cur_promo + scaled_change;
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1112
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 _old_gen_change_for_major_throughput++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1114
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 "CMSAdaptiveSizePolicy::adjust_promo_for_throughput "
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 "adjusting promo for throughput. "
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 " starting promo size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 " increased promo size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 " promo delta " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 cur_promo, desired_promo, scaled_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1124
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 return desired_promo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1127
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 size_t CMSAdaptiveSizePolicy::adjust_promo_for_footprint(size_t cur_promo,
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1130
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 set_decrease_for_footprint(decrease_young_gen_for_footprint_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1132
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 size_t change = promo_decrement(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 size_t desired_promo_size = cur_promo - change;
a61af66fc99e Initial load
duke
parents:
diff changeset
1135
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 "CMSAdaptiveSizePolicy::adjust_promo_for_footprint "
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 "adjusting promo for footprint. "
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 " starting promo size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 " reduced promo size " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 " promo delta " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 cur_promo, desired_promo_size, change);
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 return desired_promo_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1147
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 void CMSAdaptiveSizePolicy::compute_tenured_generation_free_space(
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 size_t cur_tenured_free,
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 size_t max_tenured_available,
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 // This can be bad if the desired value grows/shrinks without
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 // any connection to the read free space
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 size_t desired_promo_size = promo_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 size_t tenured_limit = max_tenured_available;
a61af66fc99e Initial load
duke
parents:
diff changeset
1156
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 // Printout input
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 if (PrintGC && PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 "CMSAdaptiveSizePolicy::compute_tenured_generation_free_space: "
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 "cur_tenured_free " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 " max_tenured_available " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 cur_tenured_free, max_tenured_available);
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1165
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 // Used for diagnostics
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 clear_generation_free_space_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
1168
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 set_decide_at_full_gc(decide_at_full_gc_true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 if (avg_remark_pause()->padded_average() > gc_pause_goal_sec() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 avg_initial_pause()->padded_average() > gc_pause_goal_sec()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 desired_promo_size = adjust_promo_for_pause_time(cur_tenured_free);
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 } else if (avg_minor_pause()->padded_average() > gc_pause_goal_sec()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 // Nothing to do since the minor collections are too large and
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 // this method only deals with the cms generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 } else if ((cms_gc_cost() >= 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 (adjusted_mutator_cost() < _throughput_goal)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 desired_promo_size = adjust_promo_for_throughput(cur_tenured_free);
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 desired_promo_size = adjust_promo_for_footprint(cur_tenured_free,
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1183
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 if (PrintGC && PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 gclog_or_tty->print_cr(
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 "CMSAdaptiveSizePolicy::compute_tenured_generation_free_space limits:"
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 " desired_promo_size: " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 " old_promo_size: " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 desired_promo_size, cur_tenured_free);
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1191
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 set_promo_size(desired_promo_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1194
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 int CMSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold(
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 bool is_survivor_overflow,
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 int tenuring_threshold,
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 size_t survivor_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 assert(survivor_limit >= generation_alignment(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 "survivor_limit too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 assert((size_t)align_size_down(survivor_limit, generation_alignment())
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 == survivor_limit, "survivor_limit not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
1203
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 // Change UsePSAdaptiveSurvivorSizePolicy -> UseAdaptiveSurvivorSizePolicy?
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 if (!UsePSAdaptiveSurvivorSizePolicy ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 !young_gen_policy_is_ready()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 return tenuring_threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1209
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 // We'll decide whether to increase or decrease the tenuring
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 // threshold based partly on the newly computed survivor size
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 // (if we hit the maximum limit allowed, we'll always choose to
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 // decrement the threshold).
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 bool incr_tenuring_threshold = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 bool decr_tenuring_threshold = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1216
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 set_decrement_tenuring_threshold_for_gc_cost(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 set_increment_tenuring_threshold_for_gc_cost(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 set_decrement_tenuring_threshold_for_survivor_limit(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1220
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 if (!is_survivor_overflow) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 // Keep running averages on how much survived
a61af66fc99e Initial load
duke
parents:
diff changeset
1223
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 // We use the tenuring threshold to equalize the cost of major
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 // and minor collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 // ThresholdTolerance is used to indicate how sensitive the
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 // tenuring threshold is to differences in cost betweent the
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 // collection types.
a61af66fc99e Initial load
duke
parents:
diff changeset
1229
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 // Get the times of interest. This involves a little work, so
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 // we cache the values here.
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 const double major_cost = major_gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 const double minor_cost = minor_gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
1234
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 if (minor_cost > major_cost * _threshold_tolerance_percent) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 // Minor times are getting too long; lower the threshold so
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 // less survives and more is promoted.
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 decr_tenuring_threshold = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 set_decrement_tenuring_threshold_for_gc_cost(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 } else if (major_cost > minor_cost * _threshold_tolerance_percent) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 // Major times are too long, so we want less promotion.
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 incr_tenuring_threshold = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 set_increment_tenuring_threshold_for_gc_cost(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1245
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 // Survivor space overflow occurred, so promoted and survived are
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 // not accurate. We'll make our best guess by combining survived
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 // and promoted and count them as survivors.
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 // We'll lower the tenuring threshold to see if we can correct
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 // things. Also, set the survivor size conservatively. We're
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 // trying to avoid many overflows from occurring if defnew size
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 // is just too small.
a61af66fc99e Initial load
duke
parents:
diff changeset
1255
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 decr_tenuring_threshold = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1258
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 // The padded average also maintains a deviation from the average;
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 // we use this to see how good of an estimate we have of what survived.
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 // We're trying to pad the survivor size as little as possible without
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 // overflowing the survivor spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 size_t target_size = align_size_up((size_t)_avg_survived->padded_average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 generation_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 target_size = MAX2(target_size, generation_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
1266
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 if (target_size > survivor_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 // Target size is bigger than we can handle. Let's also reduce
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 // the tenuring threshold.
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 target_size = survivor_limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 decr_tenuring_threshold = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 set_decrement_tenuring_threshold_for_survivor_limit(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1274
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 // Finally, increment or decrement the tenuring threshold, as decided above.
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 // We test for decrementing first, as we might have hit the target size
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 // limit.
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 if (decr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 if (tenuring_threshold > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 tenuring_threshold--;
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 } else if (incr_tenuring_threshold && !(AlwaysTenure || NeverTenure)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 if (tenuring_threshold < MaxTenuringThreshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 tenuring_threshold++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1287
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 // We keep a running average of the amount promoted which is used
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 // to decide when we should collect the old generation (when
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 // the amount of old gen free space is less than what we expect to
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 // promote).
a61af66fc99e Initial load
duke
parents:
diff changeset
1292
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 if (PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 // A little more detail if Verbose is on
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 gclog_or_tty->print( " avg_survived: %f"
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 " avg_deviation: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 _avg_survived->average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 _avg_survived->deviation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1302
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 gclog_or_tty->print( " avg_survived_padded_avg: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 _avg_survived->padded_average());
a61af66fc99e Initial load
duke
parents:
diff changeset
1305
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 gclog_or_tty->print( " avg_promoted_avg: %f"
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 " avg_promoted_dev: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 gch->gc_stats(1)->avg_promoted()->average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 gch->gc_stats(1)->avg_promoted()->deviation());
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1312
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 gclog_or_tty->print( " avg_promoted_padded_avg: %f"
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 " avg_pretenured_padded_avg: %f"
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 " tenuring_thresh: %d"
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 " target_size: " SIZE_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 " survivor_limit: " SIZE_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 gch->gc_stats(1)->avg_promoted()->padded_average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 _avg_pretenured->padded_average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 tenuring_threshold, target_size, survivor_limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 gclog_or_tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1323
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 set_survivor_size(target_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1325
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 return tenuring_threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1328
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 bool CMSAdaptiveSizePolicy::get_and_clear_first_after_collection() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 bool result = _first_after_collection;
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 _first_after_collection = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1334
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 bool CMSAdaptiveSizePolicy::print_adaptive_size_policy_on(
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1337
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 if (!UseAdaptiveSizePolicy) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1339
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 Generation* gen0 = gch->get_gen(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 DefNewGeneration* def_new = gen0->as_DefNewGeneration();
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 return
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 AdaptiveSizePolicy::print_adaptive_size_policy_on(
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 st,
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 def_new->tenuring_threshold());
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 }