annotate src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp @ 94:0834225a7916

6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction Summary: The option CMSInitiatingPermOccupancyFraction now controls perm triggering threshold. Even though the actual value of the threshold has not yet been changed, so there is no change in policy, we now have the infrastructure in place for dynamically deciding when to collect the perm gen, an issue that will be addressed in the near future. Reviewed-by: jmasa
author ysr
date Sun, 16 Mar 2008 21:57:25 -0700
parents a61af66fc99e
children 98cb887364d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // This class keeps statistical information and computes the
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // size of the heap for the concurrent mark sweep collector.
a61af66fc99e Initial load
duke
parents:
diff changeset
27 //
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // Cost for garbage collector include cost for
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // minor collection
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // concurrent collection
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // stop-the-world component
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // concurrent component
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // major compacting collection
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // uses decaying cost
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Forward decls
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class elapsedTimer;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class CMSAdaptiveSizePolicy : public AdaptiveSizePolicy {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 friend class CMSGCAdaptivePolicyCounters;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 friend class CMSCollector;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Total number of processors available
a61af66fc99e Initial load
duke
parents:
diff changeset
45 int _processor_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Number of processors used by the concurrent phases of GC
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // This number is assumed to be the same for all concurrent
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // phases.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 int _concurrent_processor_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Time that the mutators run exclusive of a particular
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // phase. For example, the time the mutators run excluding
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // the time during which the cms collector runs concurrently
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // with the mutators.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Between end of most recent cms reset and start of initial mark
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // This may be redundant
a61af66fc99e Initial load
duke
parents:
diff changeset
57 double _latest_cms_reset_end_to_initial_mark_start_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Between end of the most recent initial mark and start of remark
a61af66fc99e Initial load
duke
parents:
diff changeset
59 double _latest_cms_initial_mark_end_to_remark_start_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Between end of most recent collection and start of
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // a concurrent collection
a61af66fc99e Initial load
duke
parents:
diff changeset
62 double _latest_cms_collection_end_to_collection_start_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Times of the concurrent phases of the most recent
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // concurrent collection
a61af66fc99e Initial load
duke
parents:
diff changeset
65 double _latest_cms_concurrent_marking_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 double _latest_cms_concurrent_precleaning_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 double _latest_cms_concurrent_sweeping_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Between end of most recent STW MSC and start of next STW MSC
a61af66fc99e Initial load
duke
parents:
diff changeset
69 double _latest_cms_msc_end_to_msc_start_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Between end of most recent MS and start of next MS
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // This does not include any time spent during a concurrent
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 double _latest_cms_ms_end_to_ms_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Between start and end of the initial mark of the most recent
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // concurrent collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 double _latest_cms_initial_mark_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Between start and end of the remark phase of the most recent
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // concurrent collection
a61af66fc99e Initial load
duke
parents:
diff changeset
79 double _latest_cms_remark_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Between start and end of the most recent MS STW marking phase
a61af66fc99e Initial load
duke
parents:
diff changeset
81 double _latest_cms_ms_marking_start_to_end_time_secs;
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Pause time timers
a61af66fc99e Initial load
duke
parents:
diff changeset
84 static elapsedTimer _STW_timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // Concurrent collection timer. Used for total of all concurrent phases
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // during 1 collection cycle.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 static elapsedTimer _concurrent_timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // When the size of the generation is changed, the size
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // of the change will rounded up or down (depending on the
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // type of change) by this value.
a61af66fc99e Initial load
duke
parents:
diff changeset
92 size_t _generation_alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // If this variable is true, the size of the young generation
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // may be changed in order to reduce the pause(s) of the
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // collection of the tenured generation in order to meet the
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // pause time goal. It is common to change the size of the
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // tenured generation in order to meet the pause time goal
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // for the tenured generation. With the CMS collector for
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // the tenured generation, the size of the young generation
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // can have an significant affect on the pause times for collecting the
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // tenured generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // This is a duplicate of a variable in PSAdaptiveSizePolicy. It
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // is duplicated because it is not clear that it is general enough
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // to go into AdaptiveSizePolicy.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 int _change_young_gen_for_maj_pauses;
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Variable that is set to true after a collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 bool _first_after_collection;
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Fraction of collections that are of each type
a61af66fc99e Initial load
duke
parents:
diff changeset
112 double concurrent_fraction() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 double STW_msc_fraction() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 double STW_ms_fraction() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // This call cannot be put into the epilogue as long as some
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // of the counters can be set during concurrent phases.
a61af66fc99e Initial load
duke
parents:
diff changeset
118 virtual void clear_generation_free_space_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void set_first_after_collection() { _first_after_collection = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Average of the sum of the concurrent times for
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // one collection in seconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
125 AdaptiveWeightedAverage* _avg_concurrent_time;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Average time between concurrent collections in seconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 AdaptiveWeightedAverage* _avg_concurrent_interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Average cost of the concurrent part of a collection
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // in seconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 AdaptiveWeightedAverage* _avg_concurrent_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Average of the initial pause of a concurrent collection in seconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 AdaptivePaddedAverage* _avg_initial_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Average of the remark pause of a concurrent collection in seconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 AdaptivePaddedAverage* _avg_remark_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Average of the stop-the-world (STW) (initial mark + remark)
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // times in seconds for concurrent collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
139 AdaptiveWeightedAverage* _avg_cms_STW_time;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Average of the STW collection cost for concurrent collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
141 AdaptiveWeightedAverage* _avg_cms_STW_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Average of the bytes free at the start of the sweep.
a61af66fc99e Initial load
duke
parents:
diff changeset
144 AdaptiveWeightedAverage* _avg_cms_free_at_sweep;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // Average of the bytes free at the end of the collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
146 AdaptiveWeightedAverage* _avg_cms_free;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Average of the bytes promoted between cms collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
148 AdaptiveWeightedAverage* _avg_cms_promo;
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // stop-the-world (STW) mark-sweep-compact
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Average of the pause time in seconds for STW mark-sweep-compact
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
153 AdaptiveWeightedAverage* _avg_msc_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Average of the interval in seconds between STW mark-sweep-compact
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 AdaptiveWeightedAverage* _avg_msc_interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // Average of the collection costs for STW mark-sweep-compact
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 AdaptiveWeightedAverage* _avg_msc_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Averages for mark-sweep collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // The collection may have started as a background collection
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // that completes in a stop-the-world (STW) collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // Average of the pause time in seconds for mark-sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 AdaptiveWeightedAverage* _avg_ms_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Average of the interval in seconds between mark-sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 AdaptiveWeightedAverage* _avg_ms_interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // Average of the collection costs for mark-sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
172 AdaptiveWeightedAverage* _avg_ms_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // These variables contain a linear fit of
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // a generation size as the independent variable
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // and a pause time as the dependent variable.
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // For example _remark_pause_old_estimator
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // is a fit of the old generation size as the
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // independent variable and the remark pause
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // as the dependent variable.
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // remark pause time vs. cms gen size
a61af66fc99e Initial load
duke
parents:
diff changeset
182 LinearLeastSquareFit* _remark_pause_old_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // initial pause time vs. cms gen size
a61af66fc99e Initial load
duke
parents:
diff changeset
184 LinearLeastSquareFit* _initial_pause_old_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // remark pause time vs. young gen size
a61af66fc99e Initial load
duke
parents:
diff changeset
186 LinearLeastSquareFit* _remark_pause_young_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // initial pause time vs. young gen size
a61af66fc99e Initial load
duke
parents:
diff changeset
188 LinearLeastSquareFit* _initial_pause_young_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
191 int processor_count() const { return _processor_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 int concurrent_processor_count() const { return _concurrent_processor_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 AdaptiveWeightedAverage* avg_concurrent_time() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 return _avg_concurrent_time;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 AdaptiveWeightedAverage* avg_concurrent_interval() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 return _avg_concurrent_interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 AdaptiveWeightedAverage* avg_concurrent_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return _avg_concurrent_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 AdaptiveWeightedAverage* avg_cms_STW_time() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return _avg_cms_STW_time;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 AdaptiveWeightedAverage* avg_cms_STW_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return _avg_cms_STW_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 AdaptivePaddedAverage* avg_initial_pause() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 return _avg_initial_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 AdaptivePaddedAverage* avg_remark_pause() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return _avg_remark_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 AdaptiveWeightedAverage* avg_cms_free() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return _avg_cms_free;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 AdaptiveWeightedAverage* avg_cms_free_at_sweep() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 return _avg_cms_free_at_sweep;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 AdaptiveWeightedAverage* avg_msc_pause() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 return _avg_msc_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 AdaptiveWeightedAverage* avg_msc_interval() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return _avg_msc_interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 AdaptiveWeightedAverage* avg_msc_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return _avg_msc_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 AdaptiveWeightedAverage* avg_ms_pause() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 return _avg_ms_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 AdaptiveWeightedAverage* avg_ms_interval() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 return _avg_ms_interval;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 AdaptiveWeightedAverage* avg_ms_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 return _avg_ms_gc_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 LinearLeastSquareFit* remark_pause_old_estimator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 return _remark_pause_old_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 LinearLeastSquareFit* initial_pause_old_estimator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return _initial_pause_old_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 LinearLeastSquareFit* remark_pause_young_estimator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 return _remark_pause_young_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 LinearLeastSquareFit* initial_pause_young_estimator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return _initial_pause_young_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // These *slope() methods return the slope
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // m for the linear fit of an independent
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // variable vs. a dependent variable. For
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // example
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // remark_pause = m * old_generation_size + c
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // These may be used to determine if an
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // adjustment should be made to achieve a goal.
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // For example, if remark_pause_old_slope() is
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // positive, a reduction of the old generation
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // size has on average resulted in the reduction
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // of the remark pause.
a61af66fc99e Initial load
duke
parents:
diff changeset
278 float remark_pause_old_slope() {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return _remark_pause_old_estimator->slope();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 float initial_pause_old_slope() {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return _initial_pause_old_estimator->slope();
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 float remark_pause_young_slope() {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 return _remark_pause_young_estimator->slope();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 float initial_pause_young_slope() {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return _initial_pause_young_estimator->slope();
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Update estimators
a61af66fc99e Initial load
duke
parents:
diff changeset
295 void update_minor_pause_old_estimator(double minor_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // Fraction of processors used by the concurrent phases.
a61af66fc99e Initial load
duke
parents:
diff changeset
298 double concurrent_processor_fraction();
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // Returns the total times for the concurrent part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // latest collection in seconds.
a61af66fc99e Initial load
duke
parents:
diff changeset
302 double concurrent_collection_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Return the total times for the concurrent part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // latest collection in seconds where the times of the various
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // concurrent phases are scaled by the processor fraction used
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // during the phase.
a61af66fc99e Initial load
duke
parents:
diff changeset
308 double scaled_concurrent_collection_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // Dimensionless concurrent GC cost for all the concurrent phases.
a61af66fc99e Initial load
duke
parents:
diff changeset
311 double concurrent_collection_cost(double interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Dimensionless GC cost
a61af66fc99e Initial load
duke
parents:
diff changeset
314 double collection_cost(double pause_in_seconds, double interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 virtual GCPolicyKind kind() const { return _gc_cms_adaptive_size_policy; }
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 virtual double time_since_major_gc() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // This returns the maximum average for the concurrent, ms, and
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // msc collections. This is meant to be used for the calculation
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // of the decayed major gc cost and is not in general the
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // average of all the different types of major collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 virtual double major_gc_interval_average_for_decay() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
327 CMSAdaptiveSizePolicy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
328 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
329 size_t init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
330 double max_gc_minor_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
331 double max_gc_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
332 uint gc_cost_ratio);
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // The timers for the stop-the-world phases measure a total
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // stop-the-world time. The timer is started and stopped
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // for each phase but is only reset after the final checkpoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
337 void checkpoint_roots_initial_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 void checkpoint_roots_initial_end(GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 void checkpoint_roots_final_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
340 void checkpoint_roots_final_end(GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // Methods for gathering information about the
a61af66fc99e Initial load
duke
parents:
diff changeset
343 // concurrent marking phase of the collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // Records the mutator times and
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // resets the concurrent timer.
a61af66fc99e Initial load
duke
parents:
diff changeset
346 void concurrent_marking_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // Resets concurrent phase timer in the begin methods and
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // saves the time for a phase in the end methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
349 void concurrent_marking_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 void concurrent_sweeping_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
351 void concurrent_sweeping_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // Similar to the above (e.g., concurrent_marking_end()) and
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // is used for both the precleaning an abortable precleaing
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // phases.
a61af66fc99e Initial load
duke
parents:
diff changeset
355 void concurrent_precleaning_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
356 void concurrent_precleaning_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // Stops the concurrent phases time. Gathers
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // information and resets the timer.
a61af66fc99e Initial load
duke
parents:
diff changeset
359 void concurrent_phases_end(GCCause::Cause gc_cause,
a61af66fc99e Initial load
duke
parents:
diff changeset
360 size_t cur_eden,
a61af66fc99e Initial load
duke
parents:
diff changeset
361 size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // Methods for gather information about STW Mark-Sweep-Compact
a61af66fc99e Initial load
duke
parents:
diff changeset
364 void msc_collection_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
365 void msc_collection_end(GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Methods for gather information about Mark-Sweep done
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // in the foreground.
a61af66fc99e Initial load
duke
parents:
diff changeset
369 void ms_collection_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 void ms_collection_end(GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // Cost for a mark-sweep tenured gen collection done in the foreground
a61af66fc99e Initial load
duke
parents:
diff changeset
373 double ms_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 return MAX2(0.0F, _avg_ms_gc_cost->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // Cost of collecting the tenured generation. Includes
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // concurrent collection and STW collection costs
a61af66fc99e Initial load
duke
parents:
diff changeset
379 double cms_gc_cost() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // Cost of STW mark-sweep-compact tenured gen collection.
a61af66fc99e Initial load
duke
parents:
diff changeset
382 double msc_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 return MAX2(0.0F, _avg_msc_gc_cost->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 //
a61af66fc99e Initial load
duke
parents:
diff changeset
387 double compacting_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 double result = MIN2(1.0, minor_gc_cost() + msc_gc_cost());
a61af66fc99e Initial load
duke
parents:
diff changeset
389 assert(result >= 0.0, "Both minor and major costs are non-negative");
a61af66fc99e Initial load
duke
parents:
diff changeset
390 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // Restarts the concurrent phases timer.
a61af66fc99e Initial load
duke
parents:
diff changeset
394 void concurrent_phases_resume();
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // Time begining and end of the marking phase for
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // a synchronous MS collection. A MS collection
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // that finishes in the foreground can have started
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // in the background. These methods capture the
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // completion of the marking (after the initial
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // marking) that is done in the foreground.
a61af66fc99e Initial load
duke
parents:
diff changeset
402 void ms_collection_marking_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
403 void ms_collection_marking_end(GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 static elapsedTimer* concurrent_timer_ptr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 return &_concurrent_timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 AdaptiveWeightedAverage* avg_cms_promo() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 return _avg_cms_promo;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 int change_young_gen_for_maj_pauses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 return _change_young_gen_for_maj_pauses;
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 void set_change_young_gen_for_maj_pauses(int v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 _change_young_gen_for_maj_pauses = v;
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 void clear_internal_time_intervals();
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // Either calculated_promo_size_in_bytes() or promo_size()
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // should be deleted.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 size_t promo_size() { return _promo_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
426 void set_promo_size(size_t v) { _promo_size = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Cost of GC for all types of collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
429 virtual double gc_cost() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 size_t generation_alignment() { return _generation_alignment; }
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 virtual void compute_young_generation_free_space(size_t cur_eden,
a61af66fc99e Initial load
duke
parents:
diff changeset
434 size_t max_eden_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // Calculates new survivor space size; returns a new tenuring threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // value. Stores new survivor size in _survivor_size.
a61af66fc99e Initial load
duke
parents:
diff changeset
437 virtual int compute_survivor_space_size_and_threshold(
a61af66fc99e Initial load
duke
parents:
diff changeset
438 bool is_survivor_overflow,
a61af66fc99e Initial load
duke
parents:
diff changeset
439 int tenuring_threshold,
a61af66fc99e Initial load
duke
parents:
diff changeset
440 size_t survivor_limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 virtual void compute_tenured_generation_free_space(size_t cur_tenured_free,
a61af66fc99e Initial load
duke
parents:
diff changeset
443 size_t max_tenured_available,
a61af66fc99e Initial load
duke
parents:
diff changeset
444 size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 size_t eden_decrement_aligned_down(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 size_t eden_increment_aligned_up(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 size_t adjust_eden_for_pause_time(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 size_t adjust_eden_for_throughput(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
451 size_t adjust_eden_for_footprint(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 size_t promo_decrement_aligned_down(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
454 size_t promo_increment_aligned_up(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 size_t adjust_promo_for_pause_time(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
457 size_t adjust_promo_for_throughput(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
458 size_t adjust_promo_for_footprint(size_t cur_promo, size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 // Scale down the input size by the ratio of the cost to collect the
a61af66fc99e Initial load
duke
parents:
diff changeset
461 // generation to the total GC cost.
a61af66fc99e Initial load
duke
parents:
diff changeset
462 size_t scale_by_gen_gc_cost(size_t base_change, double gen_gc_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Return the value and clear it.
a61af66fc99e Initial load
duke
parents:
diff changeset
465 bool get_and_clear_first_after_collection();
a61af66fc99e Initial load
duke
parents:
diff changeset
466
a61af66fc99e Initial load
duke
parents:
diff changeset
467 // Printing support
a61af66fc99e Initial load
duke
parents:
diff changeset
468 virtual bool print_adaptive_size_policy_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
469 };