annotate src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp @ 1091:6aa7255741f3

6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
author ysr
date Thu, 03 Dec 2009 15:01:57 -0800
parents a61af66fc99e
children 0bfd3fb24150
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 2002-2007 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 // optimal free space for both the young and old generation
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // based on current application characteristics (based on gc cost
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // and application footprint).
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // It also computes an optimal tenuring threshold between the young
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // and old generations, so as to equalize the cost of collections
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // of those generations, as well as optimial survivor space sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // for the young generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 //
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // While this class is specifically intended for a generational system
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // consisting of a young gen (containing an Eden and two semi-spaces)
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // and a tenured gen, as well as a perm gen for reflective data, it
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // makes NO references to specific generations.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // 05/02/2003 Update
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // The 1.5 policy makes use of data gathered for the costs of GC on
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // specific generations. That data does reference specific
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // generation. Also diagnostics specific to generations have
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // been added.
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Forward decls
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class elapsedTimer;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class PSAdaptiveSizePolicy : public AdaptiveSizePolicy {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 friend class PSGCAdaptivePolicyCounters;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // These values are used to record decisions made during the
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // policy. For example, if the young generation was decreased
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // to decrease the GC cost of minor collections the value
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // decrease_young_gen_for_throughput_true is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Last calculated sizes, in bytes, and aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // NEEDS_CLEANUP should use sizes.hpp, but it works in ints, not size_t's
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Time statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
61 AdaptivePaddedAverage* _avg_major_pause;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Footprint statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
64 AdaptiveWeightedAverage* _avg_base_footprint;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Statistical data gathered for GC
a61af66fc99e Initial load
duke
parents:
diff changeset
67 GCStats _gc_stats;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 size_t _survivor_size_limit; // Limit in bytes of survivor size
a61af66fc99e Initial load
duke
parents:
diff changeset
70 const double _collection_cost_margin_fraction;
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Variable for estimating the major and minor pause times.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // These variables represent linear least-squares fits of
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // the data.
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // major pause time vs. old gen size
a61af66fc99e Initial load
duke
parents:
diff changeset
76 LinearLeastSquareFit* _major_pause_old_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // major pause time vs. young gen size
a61af66fc99e Initial load
duke
parents:
diff changeset
78 LinearLeastSquareFit* _major_pause_young_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // These record the most recent collection times. They
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // are available as an alternative to using the averages
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // for making ergonomic decisions.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 double _latest_major_mutator_interval_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 const size_t _intra_generation_alignment; // alignment for eden, survivors
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 const double _gc_minor_pause_goal_sec; // goal for maximum minor gc pause
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // The amount of live data in the heap at the last full GC, used
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // as a baseline to help us determine when we need to perform the
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // next full GC.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 size_t _live_at_last_full_gc;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // decrease/increase the old generation for minor pause time
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int _change_old_gen_for_min_pauses;
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // increase/decrease the young generation for major pause time
a61af66fc99e Initial load
duke
parents:
diff changeset
99 int _change_young_gen_for_maj_pauses;
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Flag indicating that the adaptive policy is ready to use
a61af66fc99e Initial load
duke
parents:
diff changeset
103 bool _old_gen_policy_is_ready;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Changing the generation sizing depends on the data that is
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // gathered about the effects of changes on the pause times and
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // throughput. These variable count the number of data points
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // gathered. The policy may use these counters as a threshhold
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // for reliable data.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 julong _young_gen_change_for_major_pause_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // To facilitate faster growth at start up, supplement the normal
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // growth percentage for the young gen eden and the
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // old gen space for promotion with these value which decay
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // with increasing collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 uint _young_gen_size_increment_supplement;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 uint _old_gen_size_increment_supplement;
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // The number of bytes absorbed from eden into the old gen by moving the
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // boundary over live data.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 size_t _bytes_absorbed_from_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
126 AdaptivePaddedAverage* avg_major_pause() const { return _avg_major_pause; }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 double gc_minor_pause_goal_sec() const { return _gc_minor_pause_goal_sec; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Change the young generation size to achieve a minor GC pause time goal
a61af66fc99e Initial load
duke
parents:
diff changeset
130 void adjust_for_minor_pause_time(bool is_full_gc,
a61af66fc99e Initial load
duke
parents:
diff changeset
131 size_t* desired_promo_size_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
132 size_t* desired_eden_size_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Change the generation sizes to achieve a GC pause time goal
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Returned sizes are not necessarily aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void adjust_for_pause_time(bool is_full_gc,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 size_t* desired_promo_size_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 size_t* desired_eden_size_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Change the generation sizes to achieve an application throughput goal
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Returned sizes are not necessarily aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void adjust_for_throughput(bool is_full_gc,
a61af66fc99e Initial load
duke
parents:
diff changeset
141 size_t* desired_promo_size_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
142 size_t* desired_eden_size_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Change the generation sizes to achieve minimum footprint
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Returned sizes are not aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
145 size_t adjust_promo_for_footprint(size_t desired_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
146 size_t desired_total);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 size_t adjust_eden_for_footprint(size_t desired_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
148 size_t desired_total);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Size in bytes for an increment or decrement of eden.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 virtual size_t eden_increment(size_t cur_eden, uint percent_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 virtual size_t eden_decrement(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 size_t eden_decrement_aligned_down(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 size_t eden_increment_with_supplement_aligned_up(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Size in bytes for an increment or decrement of the promotion area
a61af66fc99e Initial load
duke
parents:
diff changeset
157 virtual size_t promo_increment(size_t cur_promo, uint percent_change);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 virtual size_t promo_decrement(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 size_t promo_decrement_aligned_down(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 size_t promo_increment_with_supplement_aligned_up(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Decay the supplemental growth additive.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void decay_supplemental_growth(bool is_full_gc);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // Returns a change that has been scaled down. Result
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // is not aligned. (If useful, move to some shared
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // location.)
a61af66fc99e Initial load
duke
parents:
diff changeset
168 size_t scale_down(size_t change, double part, double total);
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Time accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Footprint accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
174 size_t live_space() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 return (size_t)(avg_base_footprint()->average() +
a61af66fc99e Initial load
duke
parents:
diff changeset
176 avg_young_live()->average() +
a61af66fc99e Initial load
duke
parents:
diff changeset
177 avg_old_live()->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 size_t free_space() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 return _eden_size + _promo_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 void set_promo_size(size_t new_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 _promo_size = new_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 void set_survivor_size(size_t new_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 _survivor_size = new_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // Update estimators
a61af66fc99e Initial load
duke
parents:
diff changeset
191 void update_minor_pause_old_estimator(double minor_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 virtual GCPolicyKind kind() const { return _gc_ps_adaptive_size_policy; }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Use by ASPSYoungGen and ASPSOldGen to limit boundary moving.
a61af66fc99e Initial load
duke
parents:
diff changeset
197 size_t eden_increment_aligned_up(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 size_t eden_increment_aligned_down(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 size_t promo_increment_aligned_up(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 size_t promo_increment_aligned_down(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 virtual size_t eden_increment(size_t cur_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 virtual size_t promo_increment(size_t cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Accessors for use by performance counters
a61af66fc99e Initial load
duke
parents:
diff changeset
206 AdaptivePaddedNoZeroDevAverage* avg_promoted() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return _gc_stats.avg_promoted();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 AdaptiveWeightedAverage* avg_base_footprint() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 return _avg_base_footprint;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Input arguments are initial free space sizes for young and old
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // generations, the initial survivor space size, the
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // alignment values and the pause & throughput goals.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 //
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // NEEDS_CLEANUP this is a singleton object
a61af66fc99e Initial load
duke
parents:
diff changeset
218 PSAdaptiveSizePolicy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
219 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
220 size_t init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
221 size_t intra_generation_alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
222 double gc_pause_goal_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
223 double gc_minor_pause_goal_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
224 uint gc_time_ratio);
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Methods indicating events of interest to the adaptive size policy,
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // called by GC algorithms. It is the responsibility of users of this
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // policy to call these methods at the correct times!
a61af66fc99e Initial load
duke
parents:
diff changeset
229 void major_collection_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 void major_collection_end(size_t amount_live, GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 //
a61af66fc99e Initial load
duke
parents:
diff changeset
233 void tenured_allocation(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 _avg_pretenured->sample(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // NEEDS_CLEANUP should use sizes.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 size_t calculated_old_free_size_in_bytes() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 return (size_t)(_promo_size + avg_promoted()->padded_average());
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 size_t average_old_live_in_bytes() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return (size_t) avg_old_live()->average();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 size_t average_promoted_in_bytes() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 return (size_t)avg_promoted()->average();
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 size_t padded_average_promoted_in_bytes() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return (size_t)avg_promoted()->padded_average();
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 int change_young_gen_for_maj_pauses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 return _change_young_gen_for_maj_pauses;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 void set_change_young_gen_for_maj_pauses(int v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 _change_young_gen_for_maj_pauses = v;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 int change_old_gen_for_min_pauses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return _change_old_gen_for_min_pauses;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 void set_change_old_gen_for_min_pauses(int v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 _change_old_gen_for_min_pauses = v;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // Return true if the old generation size was changed
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // to try to reach a pause time goal.
a61af66fc99e Initial load
duke
parents:
diff changeset
272 bool old_gen_changed_for_pauses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 bool result = _change_old_gen_for_maj_pauses != 0 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
274 _change_old_gen_for_min_pauses != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // Return true if the young generation size was changed
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // to try to reach a pause time goal.
a61af66fc99e Initial load
duke
parents:
diff changeset
280 bool young_gen_changed_for_pauses() {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 bool result = _change_young_gen_for_min_pauses != 0 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
282 _change_young_gen_for_maj_pauses != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // end flags for pause goal
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // Return true if the old generation size was changed
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // to try to reach a throughput goal.
a61af66fc99e Initial load
duke
parents:
diff changeset
289 bool old_gen_changed_for_throughput() {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 bool result = _change_old_gen_for_throughput != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Return true if the young generation size was changed
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // to try to reach a throughput goal.
a61af66fc99e Initial load
duke
parents:
diff changeset
296 bool young_gen_changed_for_throughput() {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 bool result = _change_young_gen_for_throughput != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 int decrease_for_footprint() { return _decrease_for_footprint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Accessors for estimators. The slope of the linear fit is
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // currently all that is used for making decisions.
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 LinearLeastSquareFit* major_pause_old_estimator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 return _major_pause_old_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 LinearLeastSquareFit* major_pause_young_estimator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 return _major_pause_young_estimator;
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 virtual void clear_generation_free_space_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 float major_pause_old_slope() { return _major_pause_old_estimator->slope(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 float major_pause_young_slope() {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 return _major_pause_young_estimator->slope();
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 float major_collection_slope() { return _major_collection_estimator->slope();}
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 bool old_gen_policy_is_ready() { return _old_gen_policy_is_ready; }
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Given the amount of live data in the heap, should we
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // perform a Full GC?
a61af66fc99e Initial load
duke
parents:
diff changeset
328 bool should_full_GC(size_t live_in_old_gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // Calculates optimial free space sizes for both the old and young
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // generations. Stores results in _eden_size and _promo_size.
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // Takes current used space in all generations as input, as well
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // as an indication if a full gc has just been performed, for use
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // in deciding if an OOM error should be thrown.
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void compute_generation_free_space(size_t young_live,
a61af66fc99e Initial load
duke
parents:
diff changeset
336 size_t eden_live,
a61af66fc99e Initial load
duke
parents:
diff changeset
337 size_t old_live,
a61af66fc99e Initial load
duke
parents:
diff changeset
338 size_t perm_live,
a61af66fc99e Initial load
duke
parents:
diff changeset
339 size_t cur_eden, // current eden in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
340 size_t max_old_gen_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
341 size_t max_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
342 bool is_full_gc,
a61af66fc99e Initial load
duke
parents:
diff changeset
343 GCCause::Cause gc_cause);
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // Calculates new survivor space size; returns a new tenuring threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // value. Stores new survivor size in _survivor_size.
a61af66fc99e Initial load
duke
parents:
diff changeset
347 int compute_survivor_space_size_and_threshold(bool is_survivor_overflow,
a61af66fc99e Initial load
duke
parents:
diff changeset
348 int tenuring_threshold,
a61af66fc99e Initial load
duke
parents:
diff changeset
349 size_t survivor_limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Return the maximum size of a survivor space if the young generation were of
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // size gen_size.
a61af66fc99e Initial load
duke
parents:
diff changeset
353 size_t max_survivor_size(size_t gen_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // Never allow the target survivor size to grow more than MinSurvivorRatio
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // of the young generation size. We cannot grow into a two semi-space
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // system, with Eden zero sized. Even if the survivor space grows, from()
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // might grow by moving the bottom boundary "down" -- so from space will
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // remain almost full anyway (top() will be near end(), but there will be a
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // large filler object at the bottom).
a61af66fc99e Initial load
duke
parents:
diff changeset
360 const size_t sz = gen_size / MinSurvivorRatio;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 const size_t alignment = _intra_generation_alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 return sz > alignment ? align_size_down(sz, alignment) : alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 size_t live_at_last_full_gc() {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 return _live_at_last_full_gc;
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 size_t bytes_absorbed_from_eden() const { return _bytes_absorbed_from_eden; }
a61af66fc99e Initial load
duke
parents:
diff changeset
370 void reset_bytes_absorbed_from_eden() { _bytes_absorbed_from_eden = 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 void set_bytes_absorbed_from_eden(size_t val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
373 _bytes_absorbed_from_eden = val;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // Update averages that are always used (even
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // if adaptive sizing is turned off).
a61af66fc99e Initial load
duke
parents:
diff changeset
378 void update_averages(bool is_survivor_overflow,
a61af66fc99e Initial load
duke
parents:
diff changeset
379 size_t survived,
a61af66fc99e Initial load
duke
parents:
diff changeset
380 size_t promoted);
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // Printing support
a61af66fc99e Initial load
duke
parents:
diff changeset
383 virtual bool print_adaptive_size_policy_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
384 };