src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp

Tue, 04 Feb 2020 18:13:14 +0800

author
aoqi
date
Tue, 04 Feb 2020 18:13:14 +0800
changeset 9806
758c07667682
parent 7994
04ff2f6cd0eb
parent 9796
65749db89e61
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

Merge

ysr@777 1 /*
johnc@4929 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/g1/collectionSetChooser.hpp"
jwilhelm@7369 29 #include "gc_implementation/g1/g1Allocator.hpp"
stefank@2314 30 #include "gc_implementation/g1/g1MMUTracker.hpp"
stefank@2314 31 #include "memory/collectorPolicy.hpp"
stefank@2314 32
ysr@777 33 // A G1CollectorPolicy makes policy decisions that determine the
ysr@777 34 // characteristics of the collector. Examples include:
ysr@777 35 // * choice of collection set.
ysr@777 36 // * when to collect.
ysr@777 37
ysr@777 38 class HeapRegion;
ysr@777 39 class CollectionSetChooser;
brutisso@3923 40 class G1GCPhaseTimes;
ysr@777 41
brutisso@3812 42 // TraceGen0Time collects data on _both_ young and mixed evacuation pauses
brutisso@3812 43 // (the latter may contain non-young regions - i.e. regions that are
brutisso@3812 44 // technically in Gen1) while TraceGen1Time collects data about full GCs.
zgu@3900 45 class TraceGen0TimeData : public CHeapObj<mtGC> {
brutisso@3812 46 private:
brutisso@3812 47 unsigned _young_pause_num;
brutisso@3812 48 unsigned _mixed_pause_num;
ysr@777 49
brutisso@3812 50 NumberSeq _all_stop_world_times_ms;
brutisso@3812 51 NumberSeq _all_yield_times_ms;
ysr@777 52
brutisso@3812 53 NumberSeq _total;
brutisso@3812 54 NumberSeq _other;
brutisso@3812 55 NumberSeq _root_region_scan_wait;
brutisso@3812 56 NumberSeq _parallel;
brutisso@3812 57 NumberSeq _ext_root_scan;
brutisso@3812 58 NumberSeq _satb_filtering;
brutisso@3812 59 NumberSeq _update_rs;
brutisso@3812 60 NumberSeq _scan_rs;
brutisso@3812 61 NumberSeq _obj_copy;
brutisso@3812 62 NumberSeq _termination;
brutisso@3812 63 NumberSeq _parallel_other;
brutisso@3812 64 NumberSeq _clear_ct;
ysr@777 65
brutisso@3923 66 void print_summary(const char* str, const NumberSeq* seq) const;
brutisso@3923 67 void print_summary_sd(const char* str, const NumberSeq* seq) const;
ysr@777 68
ysr@777 69 public:
brutisso@3812 70 TraceGen0TimeData() : _young_pause_num(0), _mixed_pause_num(0) {};
brutisso@3812 71 void record_start_collection(double time_to_stop_the_world_ms);
brutisso@3812 72 void record_yield_time(double yield_time_ms);
brutisso@3923 73 void record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times);
brutisso@3812 74 void increment_young_collection_count();
brutisso@3812 75 void increment_mixed_collection_count();
brutisso@3812 76 void print() const;
ysr@777 77 };
ysr@777 78
zgu@3900 79 class TraceGen1TimeData : public CHeapObj<mtGC> {
brutisso@3812 80 private:
brutisso@3812 81 NumberSeq _all_full_gc_times;
ysr@777 82
brutisso@3812 83 public:
brutisso@3812 84 void record_full_collection(double full_gc_time_ms);
brutisso@3812 85 void print() const;
ysr@777 86 };
ysr@777 87
brutisso@3358 88 // There are three command line options related to the young gen size:
brutisso@3358 89 // NewSize, MaxNewSize and NewRatio (There is also -Xmn, but that is
brutisso@3358 90 // just a short form for NewSize==MaxNewSize). G1 will use its internal
brutisso@3358 91 // heuristics to calculate the actual young gen size, so these options
brutisso@3358 92 // basically only limit the range within which G1 can pick a young gen
brutisso@3358 93 // size. Also, these are general options taking byte sizes. G1 will
brutisso@3358 94 // internally work with a number of regions instead. So, some rounding
brutisso@3358 95 // will occur.
brutisso@3358 96 //
brutisso@3358 97 // If nothing related to the the young gen size is set on the command
johnc@4385 98 // line we should allow the young gen to be between G1NewSizePercent
johnc@4385 99 // and G1MaxNewSizePercent of the heap size. This means that every time
johnc@4385 100 // the heap size changes, the limits for the young gen size will be
johnc@4385 101 // recalculated.
brutisso@3358 102 //
brutisso@3358 103 // If only -XX:NewSize is set we should use the specified value as the
johnc@4385 104 // minimum size for young gen. Still using G1MaxNewSizePercent of the
johnc@4385 105 // heap as maximum.
brutisso@3358 106 //
brutisso@3358 107 // If only -XX:MaxNewSize is set we should use the specified value as the
johnc@4385 108 // maximum size for young gen. Still using G1NewSizePercent of the heap
johnc@4385 109 // as minimum.
brutisso@3358 110 //
brutisso@3358 111 // If -XX:NewSize and -XX:MaxNewSize are both specified we use these values.
brutisso@3358 112 // No updates when the heap size changes. There is a special case when
brutisso@3358 113 // NewSize==MaxNewSize. This is interpreted as "fixed" and will use a
brutisso@3358 114 // different heuristic for calculating the collection set when we do mixed
brutisso@3358 115 // collection.
brutisso@3358 116 //
brutisso@3358 117 // If only -XX:NewRatio is set we should use the specified ratio of the heap
brutisso@3358 118 // as both min and max. This will be interpreted as "fixed" just like the
brutisso@3358 119 // NewSize==MaxNewSize case above. But we will update the min and max
brutisso@3358 120 // everytime the heap size changes.
brutisso@3358 121 //
brutisso@3358 122 // NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is
brutisso@3358 123 // combined with either NewSize or MaxNewSize. (A warning message is printed.)
zgu@3900 124 class G1YoungGenSizer : public CHeapObj<mtGC> {
brutisso@3358 125 private:
brutisso@3358 126 enum SizerKind {
brutisso@3358 127 SizerDefaults,
brutisso@3358 128 SizerNewSizeOnly,
brutisso@3358 129 SizerMaxNewSizeOnly,
brutisso@3358 130 SizerMaxAndNewSize,
brutisso@3358 131 SizerNewRatio
brutisso@3358 132 };
brutisso@3358 133 SizerKind _sizer_kind;
tonyp@3713 134 uint _min_desired_young_length;
tonyp@3713 135 uint _max_desired_young_length;
sjohanss@9796 136
sjohanss@9796 137 // False when using a fixed young generation size due to command-line options,
sjohanss@9796 138 // true otherwise.
brutisso@3358 139 bool _adaptive_size;
sjohanss@9796 140
tonyp@3713 141 uint calculate_default_min_length(uint new_number_of_heap_regions);
tonyp@3713 142 uint calculate_default_max_length(uint new_number_of_heap_regions);
brutisso@3358 143
jwilhelm@6085 144 // Update the given values for minimum and maximum young gen length in regions
jwilhelm@6085 145 // given the number of heap regions depending on the kind of sizing algorithm.
jwilhelm@6085 146 void recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length);
jwilhelm@6085 147
brutisso@3358 148 public:
brutisso@3358 149 G1YoungGenSizer();
jwilhelm@6085 150 // Calculate the maximum length of the young gen given the number of regions
jwilhelm@6085 151 // depending on the sizing algorithm.
jwilhelm@6085 152 uint max_young_length(uint number_of_heap_regions);
jwilhelm@6085 153
tonyp@3713 154 void heap_size_changed(uint new_number_of_heap_regions);
tonyp@3713 155 uint min_desired_young_length() {
brutisso@3358 156 return _min_desired_young_length;
brutisso@3358 157 }
tonyp@3713 158 uint max_desired_young_length() {
brutisso@3358 159 return _max_desired_young_length;
brutisso@3358 160 }
brutisso@3358 161 bool adaptive_young_list_length() {
brutisso@3358 162 return _adaptive_size;
brutisso@3358 163 }
brutisso@3358 164 };
brutisso@3358 165
ysr@777 166 class G1CollectorPolicy: public CollectorPolicy {
tonyp@3209 167 private:
ysr@777 168 // either equal to the number of parallel threads, if ParallelGCThreads
ysr@777 169 // has been set, or 1 otherwise
ysr@777 170 int _parallel_gc_threads;
ysr@777 171
jmasa@3294 172 // The number of GC threads currently active.
jmasa@3294 173 uintx _no_of_gc_threads;
jmasa@3294 174
ysr@777 175 enum SomePrivateConstants {
tonyp@1377 176 NumPrevPausesForHeuristics = 10
ysr@777 177 };
ysr@777 178
ysr@777 179 G1MMUTracker* _mmu_tracker;
ysr@777 180
jwilhelm@6085 181 void initialize_alignments();
ysr@777 182 void initialize_flags();
ysr@777 183
tonyp@3209 184 CollectionSetChooser* _collectionSetChooser;
ysr@777 185
brutisso@3923 186 double _full_collection_start_sec;
tonyp@3713 187 uint _cur_collection_pause_used_regions_at_start;
johnc@1325 188
ysr@777 189 // These exclude marking times.
ysr@777 190 TruncatedSeq* _recent_gc_times_ms;
ysr@777 191
ysr@777 192 TruncatedSeq* _concurrent_mark_remark_times_ms;
ysr@777 193 TruncatedSeq* _concurrent_mark_cleanup_times_ms;
ysr@777 194
brutisso@3812 195 TraceGen0TimeData _trace_gen0_time_data;
brutisso@3812 196 TraceGen1TimeData _trace_gen1_time_data;
ysr@777 197
ysr@777 198 double _stop_world_start;
ysr@777 199
tonyp@3337 200 // indicates whether we are in young or mixed GC mode
tonyp@3337 201 bool _gcs_are_young;
ysr@777 202
tonyp@3713 203 uint _young_list_target_length;
tonyp@3713 204 uint _young_list_fixed_length;
ysr@777 205
tonyp@2333 206 // The max number of regions we can extend the eden by while the GC
tonyp@2333 207 // locker is active. This should be >= _young_list_target_length;
tonyp@3713 208 uint _young_list_max_length;
tonyp@2333 209
tonyp@3337 210 bool _last_gc_was_young;
ysr@777 211
ysr@777 212 bool _during_marking;
ysr@777 213 bool _in_marking_window;
ysr@777 214 bool _in_marking_window_im;
ysr@777 215
ysr@777 216 SurvRateGroup* _short_lived_surv_rate_group;
ysr@777 217 SurvRateGroup* _survivor_surv_rate_group;
ysr@777 218 // add here any more surv rate groups
ysr@777 219
tonyp@1791 220 double _gc_overhead_perc;
tonyp@1791 221
tonyp@3119 222 double _reserve_factor;
tonyp@3713 223 uint _reserve_regions;
tonyp@3119 224
ysr@777 225 bool during_marking() {
ysr@777 226 return _during_marking;
ysr@777 227 }
ysr@777 228
ysr@777 229 enum PredictionConstants {
ysr@777 230 TruncatedSeqLength = 10
ysr@777 231 };
ysr@777 232
ysr@777 233 TruncatedSeq* _alloc_rate_ms_seq;
ysr@777 234 double _prev_collection_pause_end_ms;
ysr@777 235
ysr@777 236 TruncatedSeq* _rs_length_diff_seq;
ysr@777 237 TruncatedSeq* _cost_per_card_ms_seq;
tonyp@3337 238 TruncatedSeq* _young_cards_per_entry_ratio_seq;
tonyp@3337 239 TruncatedSeq* _mixed_cards_per_entry_ratio_seq;
ysr@777 240 TruncatedSeq* _cost_per_entry_ms_seq;
tonyp@3337 241 TruncatedSeq* _mixed_cost_per_entry_ms_seq;
ysr@777 242 TruncatedSeq* _cost_per_byte_ms_seq;
ysr@777 243 TruncatedSeq* _constant_other_time_ms_seq;
ysr@777 244 TruncatedSeq* _young_other_cost_per_region_ms_seq;
ysr@777 245 TruncatedSeq* _non_young_other_cost_per_region_ms_seq;
ysr@777 246
ysr@777 247 TruncatedSeq* _pending_cards_seq;
ysr@777 248 TruncatedSeq* _rs_lengths_seq;
ysr@777 249
ysr@777 250 TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
ysr@777 251
brutisso@3358 252 G1YoungGenSizer* _young_gen_sizer;
brutisso@3120 253
tonyp@3713 254 uint _eden_cset_region_length;
tonyp@3713 255 uint _survivor_cset_region_length;
tonyp@3713 256 uint _old_cset_region_length;
tonyp@3289 257
tonyp@3713 258 void init_cset_region_lengths(uint eden_cset_region_length,
tonyp@3713 259 uint survivor_cset_region_length);
tonyp@3289 260
tonyp@3713 261 uint eden_cset_region_length() { return _eden_cset_region_length; }
tonyp@3713 262 uint survivor_cset_region_length() { return _survivor_cset_region_length; }
tonyp@3713 263 uint old_cset_region_length() { return _old_cset_region_length; }
ysr@777 264
tonyp@3713 265 uint _free_regions_at_end_of_collection;
ysr@777 266
ysr@777 267 size_t _recorded_rs_lengths;
ysr@777 268 size_t _max_rs_lengths;
ysr@777 269 double _sigma;
ysr@777 270
ysr@777 271 size_t _rs_lengths_prediction;
ysr@777 272
tonyp@3539 273 double sigma() { return _sigma; }
ysr@777 274
ysr@777 275 // A function that prevents us putting too much stock in small sample
ysr@777 276 // sets. Returns a number between 2.0 and 1.0, depending on the number
ysr@777 277 // of samples. 5 or more samples yields one; fewer scales linearly from
ysr@777 278 // 2.0 at 1 sample to 1.0 at 5.
ysr@777 279 double confidence_factor(int samples) {
ysr@777 280 if (samples > 4) return 1.0;
ysr@777 281 else return 1.0 + sigma() * ((double)(5 - samples))/2.0;
ysr@777 282 }
ysr@777 283
ysr@777 284 double get_new_neg_prediction(TruncatedSeq* seq) {
ysr@777 285 return seq->davg() - sigma() * seq->dsd();
ysr@777 286 }
ysr@777 287
ysr@777 288 #ifndef PRODUCT
ysr@777 289 bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group);
ysr@777 290 #endif // PRODUCT
ysr@777 291
iveresov@1546 292 void adjust_concurrent_refinement(double update_rs_time,
iveresov@1546 293 double update_rs_processed_buffers,
iveresov@1546 294 double goal_ms);
iveresov@1546 295
jmasa@3294 296 uintx no_of_gc_threads() { return _no_of_gc_threads; }
jmasa@3294 297 void set_no_of_gc_threads(uintx v) { _no_of_gc_threads = v; }
jmasa@3294 298
ysr@777 299 double _pause_time_target_ms;
brutisso@3923 300
ysr@777 301 size_t _pending_cards;
ysr@777 302
ysr@777 303 public:
jmasa@3294 304 // Accessors
ysr@777 305
tonyp@3289 306 void set_region_eden(HeapRegion* hr, int young_index_in_cset) {
brutisso@7195 307 hr->set_eden();
ysr@777 308 hr->install_surv_rate_group(_short_lived_surv_rate_group);
tonyp@3289 309 hr->set_young_index_in_cset(young_index_in_cset);
ysr@777 310 }
ysr@777 311
tonyp@3289 312 void set_region_survivor(HeapRegion* hr, int young_index_in_cset) {
brutisso@7195 313 assert(hr->is_survivor(), "pre-condition");
ysr@777 314 hr->install_surv_rate_group(_survivor_surv_rate_group);
tonyp@3289 315 hr->set_young_index_in_cset(young_index_in_cset);
ysr@777 316 }
ysr@777 317
ysr@777 318 #ifndef PRODUCT
ysr@777 319 bool verify_young_ages();
ysr@777 320 #endif // PRODUCT
ysr@777 321
ysr@777 322 double get_new_prediction(TruncatedSeq* seq) {
ysr@777 323 return MAX2(seq->davg() + sigma() * seq->dsd(),
ysr@777 324 seq->davg() * confidence_factor(seq->num()));
ysr@777 325 }
ysr@777 326
ysr@777 327 void record_max_rs_lengths(size_t rs_lengths) {
ysr@777 328 _max_rs_lengths = rs_lengths;
ysr@777 329 }
ysr@777 330
ysr@777 331 size_t predict_rs_length_diff() {
ysr@777 332 return (size_t) get_new_prediction(_rs_length_diff_seq);
ysr@777 333 }
ysr@777 334
ysr@777 335 double predict_alloc_rate_ms() {
ysr@777 336 return get_new_prediction(_alloc_rate_ms_seq);
ysr@777 337 }
ysr@777 338
ysr@777 339 double predict_cost_per_card_ms() {
ysr@777 340 return get_new_prediction(_cost_per_card_ms_seq);
ysr@777 341 }
ysr@777 342
ysr@777 343 double predict_rs_update_time_ms(size_t pending_cards) {
ysr@777 344 return (double) pending_cards * predict_cost_per_card_ms();
ysr@777 345 }
ysr@777 346
tonyp@3337 347 double predict_young_cards_per_entry_ratio() {
tonyp@3337 348 return get_new_prediction(_young_cards_per_entry_ratio_seq);
ysr@777 349 }
ysr@777 350
tonyp@3337 351 double predict_mixed_cards_per_entry_ratio() {
tonyp@3337 352 if (_mixed_cards_per_entry_ratio_seq->num() < 2) {
tonyp@3337 353 return predict_young_cards_per_entry_ratio();
tonyp@3337 354 } else {
tonyp@3337 355 return get_new_prediction(_mixed_cards_per_entry_ratio_seq);
tonyp@3337 356 }
ysr@777 357 }
ysr@777 358
ysr@777 359 size_t predict_young_card_num(size_t rs_length) {
ysr@777 360 return (size_t) ((double) rs_length *
tonyp@3337 361 predict_young_cards_per_entry_ratio());
ysr@777 362 }
ysr@777 363
ysr@777 364 size_t predict_non_young_card_num(size_t rs_length) {
ysr@777 365 return (size_t) ((double) rs_length *
tonyp@3337 366 predict_mixed_cards_per_entry_ratio());
ysr@777 367 }
ysr@777 368
ysr@777 369 double predict_rs_scan_time_ms(size_t card_num) {
tonyp@3337 370 if (gcs_are_young()) {
ysr@777 371 return (double) card_num * get_new_prediction(_cost_per_entry_ms_seq);
tonyp@3337 372 } else {
tonyp@3337 373 return predict_mixed_rs_scan_time_ms(card_num);
tonyp@3337 374 }
ysr@777 375 }
ysr@777 376
tonyp@3337 377 double predict_mixed_rs_scan_time_ms(size_t card_num) {
tonyp@3337 378 if (_mixed_cost_per_entry_ms_seq->num() < 3) {
ysr@777 379 return (double) card_num * get_new_prediction(_cost_per_entry_ms_seq);
tonyp@3337 380 } else {
tonyp@3337 381 return (double) (card_num *
tonyp@3337 382 get_new_prediction(_mixed_cost_per_entry_ms_seq));
tonyp@3337 383 }
ysr@777 384 }
ysr@777 385
ysr@777 386 double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) {
tonyp@3337 387 if (_cost_per_byte_ms_during_cm_seq->num() < 3) {
tonyp@3337 388 return (1.1 * (double) bytes_to_copy) *
tonyp@3337 389 get_new_prediction(_cost_per_byte_ms_seq);
tonyp@3337 390 } else {
ysr@777 391 return (double) bytes_to_copy *
tonyp@3337 392 get_new_prediction(_cost_per_byte_ms_during_cm_seq);
tonyp@3337 393 }
ysr@777 394 }
ysr@777 395
ysr@777 396 double predict_object_copy_time_ms(size_t bytes_to_copy) {
tonyp@3337 397 if (_in_marking_window && !_in_marking_window_im) {
ysr@777 398 return predict_object_copy_time_ms_during_cm(bytes_to_copy);
tonyp@3337 399 } else {
ysr@777 400 return (double) bytes_to_copy *
tonyp@3337 401 get_new_prediction(_cost_per_byte_ms_seq);
tonyp@3337 402 }
ysr@777 403 }
ysr@777 404
ysr@777 405 double predict_constant_other_time_ms() {
ysr@777 406 return get_new_prediction(_constant_other_time_ms_seq);
ysr@777 407 }
ysr@777 408
ysr@777 409 double predict_young_other_time_ms(size_t young_num) {
tonyp@3337 410 return (double) young_num *
tonyp@3337 411 get_new_prediction(_young_other_cost_per_region_ms_seq);
ysr@777 412 }
ysr@777 413
ysr@777 414 double predict_non_young_other_time_ms(size_t non_young_num) {
tonyp@3337 415 return (double) non_young_num *
tonyp@3337 416 get_new_prediction(_non_young_other_cost_per_region_ms_seq);
ysr@777 417 }
ysr@777 418
ysr@777 419 double predict_base_elapsed_time_ms(size_t pending_cards);
ysr@777 420 double predict_base_elapsed_time_ms(size_t pending_cards,
ysr@777 421 size_t scanned_cards);
ysr@777 422 size_t predict_bytes_to_copy(HeapRegion* hr);
johnc@3998 423 double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc);
ysr@777 424
tonyp@3289 425 void set_recorded_rs_lengths(size_t rs_lengths);
johnc@1829 426
tonyp@3713 427 uint cset_region_length() { return young_cset_region_length() +
tonyp@3713 428 old_cset_region_length(); }
tonyp@3713 429 uint young_cset_region_length() { return eden_cset_region_length() +
tonyp@3713 430 survivor_cset_region_length(); }
ysr@777 431
apetrusenko@980 432 double predict_survivor_regions_evac_time();
apetrusenko@980 433
ysr@777 434 void cset_regions_freed() {
tonyp@3337 435 bool propagate = _last_gc_was_young && !_in_marking_window;
ysr@777 436 _short_lived_surv_rate_group->all_surviving_words_recorded(propagate);
ysr@777 437 _survivor_surv_rate_group->all_surviving_words_recorded(propagate);
ysr@777 438 // also call it on any more surv rate groups
ysr@777 439 }
ysr@777 440
ysr@777 441 G1MMUTracker* mmu_tracker() {
ysr@777 442 return _mmu_tracker;
ysr@777 443 }
ysr@777 444
tonyp@2011 445 double max_pause_time_ms() {
tonyp@2011 446 return _mmu_tracker->max_gc_time() * 1000.0;
tonyp@2011 447 }
tonyp@2011 448
ysr@777 449 double predict_remark_time_ms() {
ysr@777 450 return get_new_prediction(_concurrent_mark_remark_times_ms);
ysr@777 451 }
ysr@777 452
ysr@777 453 double predict_cleanup_time_ms() {
ysr@777 454 return get_new_prediction(_concurrent_mark_cleanup_times_ms);
ysr@777 455 }
ysr@777 456
ysr@777 457 // Returns an estimate of the survival rate of the region at yg-age
ysr@777 458 // "yg_age".
apetrusenko@980 459 double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) {
apetrusenko@980 460 TruncatedSeq* seq = surv_rate_group->get_seq(age);
ysr@777 461 if (seq->num() == 0)
ysr@777 462 gclog_or_tty->print("BARF! age is %d", age);
ysr@777 463 guarantee( seq->num() > 0, "invariant" );
ysr@777 464 double pred = get_new_prediction(seq);
ysr@777 465 if (pred > 1.0)
ysr@777 466 pred = 1.0;
ysr@777 467 return pred;
ysr@777 468 }
ysr@777 469
apetrusenko@980 470 double predict_yg_surv_rate(int age) {
apetrusenko@980 471 return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
apetrusenko@980 472 }
apetrusenko@980 473
ysr@777 474 double accum_yg_surv_rate_pred(int age) {
ysr@777 475 return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
ysr@777 476 }
ysr@777 477
tonyp@3209 478 private:
ysr@777 479 // Statistics kept per GC stoppage, pause or full.
ysr@777 480 TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
ysr@777 481
ysr@777 482 // Add a new GC of the given duration and end time to the record.
ysr@777 483 void update_recent_gc_times(double end_time_sec, double elapsed_ms);
ysr@777 484
ysr@777 485 // The head of the list (via "next_in_collection_set()") representing the
johnc@1829 486 // current collection set. Set from the incrementally built collection
johnc@1829 487 // set at the start of the pause.
ysr@777 488 HeapRegion* _collection_set;
johnc@1829 489
johnc@1829 490 // The number of bytes in the collection set before the pause. Set from
johnc@1829 491 // the incrementally built collection set at the start of an evacuation
johnc@3998 492 // pause, and incremented in finalize_cset() when adding old regions
johnc@3998 493 // (if any) to the collection set.
ysr@777 494 size_t _collection_set_bytes_used_before;
ysr@777 495
johnc@3998 496 // The number of bytes copied during the GC.
johnc@3998 497 size_t _bytes_copied_during_gc;
johnc@3998 498
johnc@1829 499 // The associated information that is maintained while the incremental
johnc@1829 500 // collection set is being built with young regions. Used to populate
johnc@1829 501 // the recorded info for the evacuation pause.
johnc@1829 502
johnc@1829 503 enum CSetBuildType {
johnc@1829 504 Active, // We are actively building the collection set
johnc@1829 505 Inactive // We are not actively building the collection set
johnc@1829 506 };
johnc@1829 507
johnc@1829 508 CSetBuildType _inc_cset_build_state;
johnc@1829 509
johnc@1829 510 // The head of the incrementally built collection set.
johnc@1829 511 HeapRegion* _inc_cset_head;
johnc@1829 512
johnc@1829 513 // The tail of the incrementally built collection set.
johnc@1829 514 HeapRegion* _inc_cset_tail;
johnc@1829 515
johnc@1829 516 // The number of bytes in the incrementally built collection set.
johnc@1829 517 // Used to set _collection_set_bytes_used_before at the start of
johnc@1829 518 // an evacuation pause.
johnc@1829 519 size_t _inc_cset_bytes_used_before;
johnc@1829 520
johnc@1829 521 // Used to record the highest end of heap region in collection set
johnc@1829 522 HeapWord* _inc_cset_max_finger;
johnc@1829 523
tonyp@3356 524 // The RSet lengths recorded for regions in the CSet. It is updated
tonyp@3356 525 // by the thread that adds a new region to the CSet. We assume that
tonyp@3356 526 // only one thread can be allocating a new CSet region (currently,
tonyp@3356 527 // it does so after taking the Heap_lock) hence no need to
tonyp@3356 528 // synchronize updates to this field.
johnc@1829 529 size_t _inc_cset_recorded_rs_lengths;
johnc@1829 530
tonyp@3356 531 // A concurrent refinement thread periodcially samples the young
tonyp@3356 532 // region RSets and needs to update _inc_cset_recorded_rs_lengths as
tonyp@3356 533 // the RSets grow. Instead of having to syncronize updates to that
tonyp@3356 534 // field we accumulate them in this field and add it to
tonyp@3356 535 // _inc_cset_recorded_rs_lengths_diffs at the start of a GC.
tonyp@3356 536 ssize_t _inc_cset_recorded_rs_lengths_diffs;
tonyp@3356 537
tonyp@3356 538 // The predicted elapsed time it will take to collect the regions in
tonyp@3356 539 // the CSet. This is updated by the thread that adds a new region to
tonyp@3356 540 // the CSet. See the comment for _inc_cset_recorded_rs_lengths about
tonyp@3356 541 // MT-safety assumptions.
johnc@1829 542 double _inc_cset_predicted_elapsed_time_ms;
johnc@1829 543
tonyp@3356 544 // See the comment for _inc_cset_recorded_rs_lengths_diffs.
tonyp@3356 545 double _inc_cset_predicted_elapsed_time_ms_diffs;
tonyp@3356 546
ysr@777 547 // Stash a pointer to the g1 heap.
ysr@777 548 G1CollectedHeap* _g1;
ysr@777 549
brutisso@3923 550 G1GCPhaseTimes* _phase_times;
brutisso@3923 551
ysr@777 552 // The ratio of gc time to elapsed time, computed over recent pauses.
ysr@777 553 double _recent_avg_pause_time_ratio;
ysr@777 554
ysr@777 555 double recent_avg_pause_time_ratio() {
ysr@777 556 return _recent_avg_pause_time_ratio;
ysr@777 557 }
ysr@777 558
tonyp@1794 559 // At the end of a pause we check the heap occupancy and we decide
tonyp@1794 560 // whether we will start a marking cycle during the next pause. If
tonyp@1794 561 // we decide that we want to do that, we will set this parameter to
tonyp@1794 562 // true. So, this parameter will stay true between the end of a
tonyp@1794 563 // pause and the beginning of a subsequent pause (not necessarily
tonyp@1794 564 // the next one, see the comments on the next field) when we decide
tonyp@1794 565 // that we will indeed start a marking cycle and do the initial-mark
tonyp@1794 566 // work.
tonyp@1794 567 volatile bool _initiate_conc_mark_if_possible;
ysr@777 568
tonyp@1794 569 // If initiate_conc_mark_if_possible() is set at the beginning of a
tonyp@1794 570 // pause, it is a suggestion that the pause should start a marking
tonyp@1794 571 // cycle by doing the initial-mark work. However, it is possible
tonyp@1794 572 // that the concurrent marking thread is still finishing up the
tonyp@1794 573 // previous marking cycle (e.g., clearing the next marking
tonyp@1794 574 // bitmap). If that is the case we cannot start a new cycle and
tonyp@1794 575 // we'll have to wait for the concurrent marking thread to finish
tonyp@1794 576 // what it is doing. In this case we will postpone the marking cycle
tonyp@1794 577 // initiation decision for the next pause. When we eventually decide
tonyp@1794 578 // to start a cycle, we will set _during_initial_mark_pause which
tonyp@1794 579 // will stay true until the end of the initial-mark pause and it's
tonyp@1794 580 // the condition that indicates that a pause is doing the
tonyp@1794 581 // initial-mark work.
tonyp@1794 582 volatile bool _during_initial_mark_pause;
tonyp@1794 583
tonyp@3337 584 bool _last_young_gc;
ysr@777 585
ysr@777 586 // This set of variables tracks the collector efficiency, in order to
ysr@777 587 // determine whether we should initiate a new marking.
ysr@777 588 double _cur_mark_stop_world_time_ms;
ysr@777 589 double _mark_remark_start_sec;
ysr@777 590 double _mark_cleanup_start_sec;
ysr@777 591
tonyp@3119 592 // Update the young list target length either by setting it to the
tonyp@3119 593 // desired fixed value or by calculating it using G1's pause
tonyp@3119 594 // prediction model. If no rs_lengths parameter is passed, predict
tonyp@3119 595 // the RS lengths using the prediction model, otherwise use the
tonyp@3119 596 // given rs_lengths as the prediction.
tonyp@3119 597 void update_young_list_target_length(size_t rs_lengths = (size_t) -1);
tonyp@3119 598
tonyp@3119 599 // Calculate and return the minimum desired young list target
tonyp@3119 600 // length. This is the minimum desired young list length according
tonyp@3119 601 // to the user's inputs.
tonyp@3713 602 uint calculate_young_list_desired_min_length(uint base_min_length);
tonyp@3119 603
tonyp@3119 604 // Calculate and return the maximum desired young list target
tonyp@3119 605 // length. This is the maximum desired young list length according
tonyp@3119 606 // to the user's inputs.
tonyp@3713 607 uint calculate_young_list_desired_max_length();
tonyp@3119 608
tonyp@3119 609 // Calculate and return the maximum young list target length that
tonyp@3119 610 // can fit into the pause time goal. The parameters are: rs_lengths
tonyp@3119 611 // represent the prediction of how large the young RSet lengths will
tonyp@3119 612 // be, base_min_length is the alreay existing number of regions in
tonyp@3119 613 // the young list, min_length and max_length are the desired min and
tonyp@3119 614 // max young list length according to the user's inputs.
tonyp@3713 615 uint calculate_young_list_target_length(size_t rs_lengths,
tonyp@3713 616 uint base_min_length,
tonyp@3713 617 uint desired_min_length,
tonyp@3713 618 uint desired_max_length);
tonyp@3119 619
tonyp@3119 620 // Check whether a given young length (young_length) fits into the
tonyp@3119 621 // given target pause time and whether the prediction for the amount
tonyp@3119 622 // of objects to be copied for the given length will fit into the
tonyp@3119 623 // given free space (expressed by base_free_regions). It is used by
tonyp@3119 624 // calculate_young_list_target_length().
tonyp@3713 625 bool predict_will_fit(uint young_length, double base_time_ms,
tonyp@3713 626 uint base_free_regions, double target_pause_time_ms);
ysr@777 627
johnc@4681 628 // Calculate the minimum number of old regions we'll add to the CSet
johnc@4681 629 // during a mixed GC.
johnc@4681 630 uint calc_min_old_cset_length();
johnc@4681 631
johnc@4681 632 // Calculate the maximum number of old regions we'll add to the CSet
johnc@4681 633 // during a mixed GC.
johnc@4681 634 uint calc_max_old_cset_length();
johnc@4681 635
johnc@4681 636 // Returns the given amount of uncollected reclaimable space
johnc@4681 637 // as a percentage of the current heap capacity.
johnc@4681 638 double reclaimable_bytes_perc(size_t reclaimable_bytes);
johnc@4681 639
ysr@777 640 public:
ysr@777 641
ysr@777 642 G1CollectorPolicy();
ysr@777 643
ysr@777 644 virtual G1CollectorPolicy* as_g1_policy() { return this; }
ysr@777 645
ysr@777 646 virtual CollectorPolicy::Name kind() {
ysr@777 647 return CollectorPolicy::G1CollectorPolicyKind;
ysr@777 648 }
ysr@777 649
brutisso@3923 650 G1GCPhaseTimes* phase_times() const { return _phase_times; }
brutisso@3923 651
tonyp@3119 652 // Check the current value of the young list RSet lengths and
tonyp@3119 653 // compare it against the last prediction. If the current value is
tonyp@3119 654 // higher, recalculate the young list target length prediction.
tonyp@3119 655 void revise_young_list_target_length_if_necessary();
ysr@777 656
brutisso@3120 657 // This should be called after the heap is resized.
tonyp@3713 658 void record_new_heap_size(uint new_number_of_regions);
tonyp@3119 659
tonyp@3209 660 void init();
ysr@777 661
apetrusenko@980 662 // Create jstat counters for the policy.
apetrusenko@980 663 virtual void initialize_gc_policy_counters();
apetrusenko@980 664
ysr@777 665 virtual HeapWord* mem_allocate_work(size_t size,
ysr@777 666 bool is_tlab,
ysr@777 667 bool* gc_overhead_limit_was_exceeded);
ysr@777 668
ysr@777 669 // This method controls how a collector handles one or more
ysr@777 670 // of its generations being fully allocated.
ysr@777 671 virtual HeapWord* satisfy_failed_allocation(size_t size,
ysr@777 672 bool is_tlab);
ysr@777 673
ysr@777 674 BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
ysr@777 675
brutisso@3461 676 bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0);
brutisso@3456 677
johnc@4929 678 // Record the start and end of an evacuation pause.
johnc@4929 679 void record_collection_pause_start(double start_time_sec);
sla@5237 680 void record_collection_pause_end(double pause_time_ms, EvacuationInfo& evacuation_info);
ysr@777 681
johnc@4929 682 // Record the start and end of a full collection.
johnc@4929 683 void record_full_collection_start();
johnc@4929 684 void record_full_collection_end();
ysr@777 685
ysr@777 686 // Must currently be called while the world is stopped.
johnc@4929 687 void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms);
ysr@777 688
johnc@4929 689 // Record start and end of remark.
tonyp@3209 690 void record_concurrent_mark_remark_start();
tonyp@3209 691 void record_concurrent_mark_remark_end();
ysr@777 692
johnc@4929 693 // Record start, end, and completion of cleanup.
tonyp@3209 694 void record_concurrent_mark_cleanup_start();
jmasa@3294 695 void record_concurrent_mark_cleanup_end(int no_of_gc_threads);
tonyp@3209 696 void record_concurrent_mark_cleanup_completed();
ysr@777 697
johnc@4929 698 // Records the information about the heap size for reporting in
johnc@4929 699 // print_detailed_heap_transition
johnc@5123 700 void record_heap_size_info_at_start(bool full);
ysr@777 701
johnc@4929 702 // Print heap sizing transition (with less and more detail).
tonyp@2961 703 void print_heap_transition();
johnc@5123 704 void print_detailed_heap_transition(bool full = false);
ysr@777 705
johnc@4929 706 void record_stop_world_start();
johnc@4929 707 void record_concurrent_pause();
ysr@777 708
tonyp@3028 709 // Record how much space we copied during a GC. This is typically
tonyp@3028 710 // called when a GC alloc region is being retired.
tonyp@3028 711 void record_bytes_copied_during_gc(size_t bytes) {
tonyp@3028 712 _bytes_copied_during_gc += bytes;
tonyp@3028 713 }
tonyp@3028 714
tonyp@3028 715 // The amount of space we copied during a GC.
tonyp@3028 716 size_t bytes_copied_during_gc() {
tonyp@3028 717 return _bytes_copied_during_gc;
tonyp@3028 718 }
ysr@777 719
brutisso@3675 720 // Determine whether there are candidate regions so that the
brutisso@3675 721 // next GC should be mixed. The two action strings are used
brutisso@3675 722 // in the ergo output when the method returns true or false.
tonyp@3539 723 bool next_gc_should_be_mixed(const char* true_action_str,
tonyp@3539 724 const char* false_action_str);
tonyp@3539 725
ysr@777 726 // Choose a new collection set. Marks the chosen regions as being
ysr@777 727 // "in_collection_set", and links them together. The head and number of
ysr@777 728 // the collection set are available via access methods.
sla@5237 729 void finalize_cset(double target_pause_time_ms, EvacuationInfo& evacuation_info);
ysr@777 730
ysr@777 731 // The head of the list (via "next_in_collection_set()") representing the
ysr@777 732 // current collection set.
ysr@777 733 HeapRegion* collection_set() { return _collection_set; }
ysr@777 734
johnc@1829 735 void clear_collection_set() { _collection_set = NULL; }
johnc@1829 736
tonyp@3289 737 // Add old region "hr" to the CSet.
tonyp@3289 738 void add_old_region_to_cset(HeapRegion* hr);
ysr@777 739
johnc@1829 740 // Incremental CSet Support
johnc@1829 741
johnc@1829 742 // The head of the incrementally built collection set.
johnc@1829 743 HeapRegion* inc_cset_head() { return _inc_cset_head; }
johnc@1829 744
johnc@1829 745 // The tail of the incrementally built collection set.
johnc@1829 746 HeapRegion* inc_set_tail() { return _inc_cset_tail; }
johnc@1829 747
johnc@1829 748 // Initialize incremental collection set info.
johnc@1829 749 void start_incremental_cset_building();
johnc@1829 750
tonyp@3356 751 // Perform any final calculations on the incremental CSet fields
tonyp@3356 752 // before we can use them.
tonyp@3356 753 void finalize_incremental_cset_building();
tonyp@3356 754
johnc@1829 755 void clear_incremental_cset() {
johnc@1829 756 _inc_cset_head = NULL;
johnc@1829 757 _inc_cset_tail = NULL;
johnc@1829 758 }
johnc@1829 759
johnc@1829 760 // Stop adding regions to the incremental collection set
johnc@1829 761 void stop_incremental_cset_building() { _inc_cset_build_state = Inactive; }
johnc@1829 762
tonyp@3356 763 // Add information about hr to the aggregated information for the
tonyp@3356 764 // incrementally built collection set.
johnc@1829 765 void add_to_incremental_cset_info(HeapRegion* hr, size_t rs_length);
johnc@1829 766
johnc@1829 767 // Update information about hr in the aggregated information for
johnc@1829 768 // the incrementally built collection set.
johnc@1829 769 void update_incremental_cset_info(HeapRegion* hr, size_t new_rs_length);
johnc@1829 770
johnc@1829 771 private:
johnc@1829 772 // Update the incremental cset information when adding a region
johnc@1829 773 // (should not be called directly).
johnc@1829 774 void add_region_to_incremental_cset_common(HeapRegion* hr);
johnc@1829 775
johnc@1829 776 public:
johnc@1829 777 // Add hr to the LHS of the incremental collection set.
johnc@1829 778 void add_region_to_incremental_cset_lhs(HeapRegion* hr);
johnc@1829 779
johnc@1829 780 // Add hr to the RHS of the incremental collection set.
johnc@1829 781 void add_region_to_incremental_cset_rhs(HeapRegion* hr);
johnc@1829 782
johnc@1829 783 #ifndef PRODUCT
johnc@1829 784 void print_collection_set(HeapRegion* list_head, outputStream* st);
johnc@1829 785 #endif // !PRODUCT
johnc@1829 786
tonyp@1794 787 bool initiate_conc_mark_if_possible() { return _initiate_conc_mark_if_possible; }
tonyp@1794 788 void set_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = true; }
tonyp@1794 789 void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; }
tonyp@1794 790
tonyp@1794 791 bool during_initial_mark_pause() { return _during_initial_mark_pause; }
tonyp@1794 792 void set_during_initial_mark_pause() { _during_initial_mark_pause = true; }
tonyp@1794 793 void clear_during_initial_mark_pause(){ _during_initial_mark_pause = false; }
tonyp@1794 794
tonyp@2011 795 // This sets the initiate_conc_mark_if_possible() flag to start a
tonyp@2011 796 // new cycle, as long as we are not already in one. It's best if it
tonyp@2011 797 // is called during a safepoint when the test whether a cycle is in
tonyp@2011 798 // progress or not is stable.
tonyp@3114 799 bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause);
tonyp@2011 800
tonyp@1794 801 // This is called at the very beginning of an evacuation pause (it
tonyp@1794 802 // has to be the first thing that the pause does). If
tonyp@1794 803 // initiate_conc_mark_if_possible() is true, and the concurrent
tonyp@1794 804 // marking thread has completed its work during the previous cycle,
tonyp@1794 805 // it will set during_initial_mark_pause() to so that the pause does
tonyp@1794 806 // the initial-mark work and start a marking cycle.
tonyp@1794 807 void decide_on_conc_mark_initiation();
ysr@777 808
ysr@777 809 // If an expansion would be appropriate, because recent GC overhead had
ysr@777 810 // exceeded the desired limit, return an amount to expand by.
jwilhelm@7369 811 virtual size_t expansion_amount();
ysr@777 812
ysr@777 813 // Print tracing information.
ysr@777 814 void print_tracing_info() const;
ysr@777 815
ysr@777 816 // Print stats on young survival ratio
ysr@777 817 void print_yg_surv_rate_info() const;
ysr@777 818
apetrusenko@980 819 void finished_recalculating_age_indexes(bool is_survivors) {
apetrusenko@980 820 if (is_survivors) {
apetrusenko@980 821 _survivor_surv_rate_group->finished_recalculating_age_indexes();
apetrusenko@980 822 } else {
apetrusenko@980 823 _short_lived_surv_rate_group->finished_recalculating_age_indexes();
apetrusenko@980 824 }
ysr@777 825 // do that for any other surv rate groups
ysr@777 826 }
ysr@777 827
brutisso@6376 828 size_t young_list_target_length() const { return _young_list_target_length; }
brutisso@6376 829
jwilhelm@7369 830 bool is_young_list_full();
tonyp@2333 831
jwilhelm@7369 832 bool can_expand_young_list();
tonyp@2315 833
tonyp@3713 834 uint young_list_max_length() {
tonyp@3176 835 return _young_list_max_length;
tonyp@3176 836 }
tonyp@3176 837
tonyp@3337 838 bool gcs_are_young() {
tonyp@3337 839 return _gcs_are_young;
ysr@777 840 }
tonyp@3337 841 void set_gcs_are_young(bool gcs_are_young) {
tonyp@3337 842 _gcs_are_young = gcs_are_young;
ysr@777 843 }
ysr@777 844
ysr@777 845 bool adaptive_young_list_length() {
brutisso@3358 846 return _young_gen_sizer->adaptive_young_list_length();
ysr@777 847 }
ysr@777 848
tonyp@3209 849 private:
ysr@777 850 //
ysr@777 851 // Survivor regions policy.
ysr@777 852 //
ysr@777 853
ysr@777 854 // Current tenuring threshold, set to 0 if the collector reaches the
jwilhelm@4129 855 // maximum amount of survivors regions.
jwilhelm@4129 856 uint _tenuring_threshold;
ysr@777 857
apetrusenko@980 858 // The limit on the number of regions allocated for survivors.
tonyp@3713 859 uint _max_survivor_regions;
apetrusenko@980 860
tonyp@2961 861 // For reporting purposes.
johnc@5123 862 // The value of _heap_bytes_before_gc is also used to calculate
johnc@5123 863 // the cost of copying.
johnc@5123 864
johnc@5123 865 size_t _eden_used_bytes_before_gc; // Eden occupancy before GC
johnc@5123 866 size_t _survivor_used_bytes_before_gc; // Survivor occupancy before GC
johnc@5123 867 size_t _heap_used_bytes_before_gc; // Heap occupancy before GC
johnc@5123 868 size_t _metaspace_used_bytes_before_gc; // Metaspace occupancy before GC
johnc@5123 869
johnc@5123 870 size_t _eden_capacity_bytes_before_gc; // Eden capacity before GC
johnc@5123 871 size_t _heap_capacity_bytes_before_gc; // Heap capacity before GC
tonyp@2961 872
jwilhelm@4129 873 // The amount of survivor regions after a collection.
tonyp@3713 874 uint _recorded_survivor_regions;
apetrusenko@980 875 // List of survivor regions.
apetrusenko@980 876 HeapRegion* _recorded_survivor_head;
apetrusenko@980 877 HeapRegion* _recorded_survivor_tail;
apetrusenko@980 878
apetrusenko@980 879 ageTable _survivors_age_table;
apetrusenko@980 880
ysr@777 881 public:
sla@5237 882 uint tenuring_threshold() const { return _tenuring_threshold; }
ysr@777 883
tonyp@3713 884 static const uint REGIONS_UNLIMITED = (uint) -1;
apetrusenko@980 885
tschatzl@7651 886 uint max_regions(InCSetState dest) {
tschatzl@7651 887 switch (dest.value()) {
tschatzl@7651 888 case InCSetState::Young:
tschatzl@7651 889 return _max_survivor_regions;
tschatzl@7651 890 case InCSetState::Old:
tschatzl@7651 891 return REGIONS_UNLIMITED;
tschatzl@7651 892 default:
tschatzl@7651 893 assert(false, err_msg("Unknown dest state: " CSETSTATE_FORMAT, dest.value()));
tschatzl@7651 894 break;
ysr@777 895 }
tschatzl@7651 896 // keep some compilers happy
tschatzl@7651 897 return 0;
ysr@777 898 }
ysr@777 899
ysr@777 900 void note_start_adding_survivor_regions() {
ysr@777 901 _survivor_surv_rate_group->start_adding_regions();
ysr@777 902 }
ysr@777 903
ysr@777 904 void note_stop_adding_survivor_regions() {
ysr@777 905 _survivor_surv_rate_group->stop_adding_regions();
ysr@777 906 }
apetrusenko@980 907
tonyp@3713 908 void record_survivor_regions(uint regions,
apetrusenko@980 909 HeapRegion* head,
apetrusenko@980 910 HeapRegion* tail) {
apetrusenko@980 911 _recorded_survivor_regions = regions;
apetrusenko@980 912 _recorded_survivor_head = head;
apetrusenko@980 913 _recorded_survivor_tail = tail;
apetrusenko@980 914 }
apetrusenko@980 915
tonyp@3713 916 uint recorded_survivor_regions() {
tonyp@1273 917 return _recorded_survivor_regions;
tonyp@1273 918 }
tonyp@1273 919
tonyp@3713 920 void record_thread_age_table(ageTable* age_table) {
apetrusenko@980 921 _survivors_age_table.merge_par(age_table);
apetrusenko@980 922 }
apetrusenko@980 923
tonyp@3119 924 void update_max_gc_locker_expansion();
tonyp@2333 925
apetrusenko@980 926 // Calculates survivor space parameters.
tonyp@3119 927 void update_survivors_policy();
apetrusenko@980 928
jwilhelm@6085 929 virtual void post_heap_initialize();
ysr@777 930 };
ysr@777 931
ysr@777 932 // This should move to some place more general...
ysr@777 933
ysr@777 934 // If we have "n" measurements, and we've kept track of their "sum" and the
ysr@777 935 // "sum_of_squares" of the measurements, this returns the variance of the
ysr@777 936 // sequence.
ysr@777 937 inline double variance(int n, double sum_of_squares, double sum) {
ysr@777 938 double n_d = (double)n;
ysr@777 939 double avg = sum/n_d;
ysr@777 940 return (sum_of_squares - 2.0 * avg * sum + n_d * avg * avg) / n_d;
ysr@777 941 }
ysr@777 942
stefank@2314 943 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP

mercurial