Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp @ 13060:8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
7057939: jmap shows MaxNewSize=4GB when Java is using parallel collector
Summary: Major cleanup of the collectorpolicy classes
Reviewed-by: tschatzl, jcoomes
author | jwilhelm |
---|---|
date | Fri, 01 Nov 2013 17:09:38 +0100 |
parents | 46d7652b223c |
children | 63a4eb8bcd23 a034dc5e910b |
comparison
equal
deleted
inserted
replaced
13059:46d7652b223c | 13060:8f07aa079343 |
---|---|
35 #include <math.h> | 35 #include <math.h> |
36 | 36 |
37 PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size, | 37 PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size, |
38 size_t init_promo_size, | 38 size_t init_promo_size, |
39 size_t init_survivor_size, | 39 size_t init_survivor_size, |
40 size_t intra_generation_alignment, | 40 size_t space_alignment, |
41 double gc_pause_goal_sec, | 41 double gc_pause_goal_sec, |
42 double gc_minor_pause_goal_sec, | 42 double gc_minor_pause_goal_sec, |
43 uint gc_cost_ratio) : | 43 uint gc_cost_ratio) : |
44 AdaptiveSizePolicy(init_eden_size, | 44 AdaptiveSizePolicy(init_eden_size, |
45 init_promo_size, | 45 init_promo_size, |
46 init_survivor_size, | 46 init_survivor_size, |
47 gc_pause_goal_sec, | 47 gc_pause_goal_sec, |
48 gc_cost_ratio), | 48 gc_cost_ratio), |
49 _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0), | 49 _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0), |
50 _intra_generation_alignment(intra_generation_alignment), | 50 _space_alignment(space_alignment), |
51 _live_at_last_full_gc(init_promo_size), | 51 _live_at_last_full_gc(init_promo_size), |
52 _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec), | 52 _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec), |
53 _latest_major_mutator_interval_seconds(0), | 53 _latest_major_mutator_interval_seconds(0), |
54 _young_gen_change_for_major_pause_count(0) | 54 _young_gen_change_for_major_pause_count(0) |
55 { | 55 { |
350 gc_cost(), GCTimeLimit); | 350 gc_cost(), GCTimeLimit); |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 // Align everything and make a final limit check | 354 // Align everything and make a final limit check |
355 const size_t alignment = _intra_generation_alignment; | 355 desired_eden_size = align_size_up(desired_eden_size, _space_alignment); |
356 desired_eden_size = align_size_up(desired_eden_size, alignment); | 356 desired_eden_size = MAX2(desired_eden_size, _space_alignment); |
357 desired_eden_size = MAX2(desired_eden_size, alignment); | 357 |
358 | 358 eden_limit = align_size_down(eden_limit, _space_alignment); |
359 eden_limit = align_size_down(eden_limit, alignment); | |
360 | 359 |
361 // And one last limit check, now that we've aligned things. | 360 // And one last limit check, now that we've aligned things. |
362 if (desired_eden_size > eden_limit) { | 361 if (desired_eden_size > eden_limit) { |
363 // If the policy says to get a larger eden but | 362 // If the policy says to get a larger eden but |
364 // is hitting the limit, don't decrease eden. | 363 // is hitting the limit, don't decrease eden. |
558 gc_cost(), GCTimeLimit); | 557 gc_cost(), GCTimeLimit); |
559 } | 558 } |
560 } | 559 } |
561 | 560 |
562 // Align everything and make a final limit check | 561 // Align everything and make a final limit check |
563 const size_t alignment = _intra_generation_alignment; | 562 desired_promo_size = align_size_up(desired_promo_size, _space_alignment); |
564 desired_promo_size = align_size_up(desired_promo_size, alignment); | 563 desired_promo_size = MAX2(desired_promo_size, _space_alignment); |
565 desired_promo_size = MAX2(desired_promo_size, alignment); | 564 |
566 | 565 promo_limit = align_size_down(promo_limit, _space_alignment); |
567 promo_limit = align_size_down(promo_limit, alignment); | |
568 | 566 |
569 // And one last limit check, now that we've aligned things. | 567 // And one last limit check, now that we've aligned things. |
570 desired_promo_size = MIN2(desired_promo_size, promo_limit); | 568 desired_promo_size = MIN2(desired_promo_size, promo_limit); |
571 | 569 |
572 if (PrintAdaptiveSizePolicy) { | 570 if (PrintAdaptiveSizePolicy) { |
647 if (is_full_gc) { | 645 if (is_full_gc) { |
648 set_decide_at_full_gc(decide_at_full_gc_true); | 646 set_decide_at_full_gc(decide_at_full_gc_true); |
649 } | 647 } |
650 // If the desired eden size is as small as it will get, | 648 // If the desired eden size is as small as it will get, |
651 // try to adjust the old gen size. | 649 // try to adjust the old gen size. |
652 if (*desired_eden_size_ptr <= _intra_generation_alignment) { | 650 if (*desired_eden_size_ptr <= _space_alignment) { |
653 // Vary the old gen size to reduce the young gen pause. This | 651 // Vary the old gen size to reduce the young gen pause. This |
654 // may not be a good idea. This is just a test. | 652 // may not be a good idea. This is just a test. |
655 if (minor_pause_old_estimator()->decrement_will_decrease()) { | 653 if (minor_pause_old_estimator()->decrement_will_decrease()) { |
656 set_change_old_gen_for_min_pauses(decrease_old_gen_for_min_pauses_true); | 654 set_change_old_gen_for_min_pauses(decrease_old_gen_for_min_pauses_true); |
657 *desired_promo_size_ptr = | 655 *desired_promo_size_ptr = |
752 // affects of a change can only be seen at full gc's. | 750 // affects of a change can only be seen at full gc's. |
753 if (PSAdjustYoungGenForMajorPause) { | 751 if (PSAdjustYoungGenForMajorPause) { |
754 // If the promo size is at the minimum (i.e., the old gen | 752 // If the promo size is at the minimum (i.e., the old gen |
755 // size will not actually decrease), consider changing the | 753 // size will not actually decrease), consider changing the |
756 // young gen size. | 754 // young gen size. |
757 if (*desired_promo_size_ptr < _intra_generation_alignment) { | 755 if (*desired_promo_size_ptr < _space_alignment) { |
758 // If increasing the young generation will decrease the old gen | 756 // If increasing the young generation will decrease the old gen |
759 // pause, do it. | 757 // pause, do it. |
760 // During startup there is noise in the statistics for deciding | 758 // During startup there is noise in the statistics for deciding |
761 // on whether to increase or decrease the young gen size. For | 759 // on whether to increase or decrease the young gen size. For |
762 // some number of iterations, just try to increase the young | 760 // some number of iterations, just try to increase the young |
1063 return eden_increment(cur_eden, YoungGenerationSizeIncrement); | 1061 return eden_increment(cur_eden, YoungGenerationSizeIncrement); |
1064 } | 1062 } |
1065 | 1063 |
1066 size_t PSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { | 1064 size_t PSAdaptiveSizePolicy::eden_increment_aligned_up(size_t cur_eden) { |
1067 size_t result = eden_increment(cur_eden, YoungGenerationSizeIncrement); | 1065 size_t result = eden_increment(cur_eden, YoungGenerationSizeIncrement); |
1068 return align_size_up(result, _intra_generation_alignment); | 1066 return align_size_up(result, _space_alignment); |
1069 } | 1067 } |
1070 | 1068 |
1071 size_t PSAdaptiveSizePolicy::eden_increment_aligned_down(size_t cur_eden) { | 1069 size_t PSAdaptiveSizePolicy::eden_increment_aligned_down(size_t cur_eden) { |
1072 size_t result = eden_increment(cur_eden); | 1070 size_t result = eden_increment(cur_eden); |
1073 return align_size_down(result, _intra_generation_alignment); | 1071 return align_size_down(result, _space_alignment); |
1074 } | 1072 } |
1075 | 1073 |
1076 size_t PSAdaptiveSizePolicy::eden_increment_with_supplement_aligned_up( | 1074 size_t PSAdaptiveSizePolicy::eden_increment_with_supplement_aligned_up( |
1077 size_t cur_eden) { | 1075 size_t cur_eden) { |
1078 size_t result = eden_increment(cur_eden, | 1076 size_t result = eden_increment(cur_eden, |
1079 YoungGenerationSizeIncrement + _young_gen_size_increment_supplement); | 1077 YoungGenerationSizeIncrement + _young_gen_size_increment_supplement); |
1080 return align_size_up(result, _intra_generation_alignment); | 1078 return align_size_up(result, _space_alignment); |
1081 } | 1079 } |
1082 | 1080 |
1083 size_t PSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { | 1081 size_t PSAdaptiveSizePolicy::eden_decrement_aligned_down(size_t cur_eden) { |
1084 size_t eden_heap_delta = eden_decrement(cur_eden); | 1082 size_t eden_heap_delta = eden_decrement(cur_eden); |
1085 return align_size_down(eden_heap_delta, _intra_generation_alignment); | 1083 return align_size_down(eden_heap_delta, _space_alignment); |
1086 } | 1084 } |
1087 | 1085 |
1088 size_t PSAdaptiveSizePolicy::eden_decrement(size_t cur_eden) { | 1086 size_t PSAdaptiveSizePolicy::eden_decrement(size_t cur_eden) { |
1089 size_t eden_heap_delta = eden_increment(cur_eden) / | 1087 size_t eden_heap_delta = eden_increment(cur_eden) / |
1090 AdaptiveSizeDecrementScaleFactor; | 1088 AdaptiveSizeDecrementScaleFactor; |
1102 return promo_increment(cur_promo, TenuredGenerationSizeIncrement); | 1100 return promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
1103 } | 1101 } |
1104 | 1102 |
1105 size_t PSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { | 1103 size_t PSAdaptiveSizePolicy::promo_increment_aligned_up(size_t cur_promo) { |
1106 size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); | 1104 size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
1107 return align_size_up(result, _intra_generation_alignment); | 1105 return align_size_up(result, _space_alignment); |
1108 } | 1106 } |
1109 | 1107 |
1110 size_t PSAdaptiveSizePolicy::promo_increment_aligned_down(size_t cur_promo) { | 1108 size_t PSAdaptiveSizePolicy::promo_increment_aligned_down(size_t cur_promo) { |
1111 size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); | 1109 size_t result = promo_increment(cur_promo, TenuredGenerationSizeIncrement); |
1112 return align_size_down(result, _intra_generation_alignment); | 1110 return align_size_down(result, _space_alignment); |
1113 } | 1111 } |
1114 | 1112 |
1115 size_t PSAdaptiveSizePolicy::promo_increment_with_supplement_aligned_up( | 1113 size_t PSAdaptiveSizePolicy::promo_increment_with_supplement_aligned_up( |
1116 size_t cur_promo) { | 1114 size_t cur_promo) { |
1117 size_t result = promo_increment(cur_promo, | 1115 size_t result = promo_increment(cur_promo, |
1118 TenuredGenerationSizeIncrement + _old_gen_size_increment_supplement); | 1116 TenuredGenerationSizeIncrement + _old_gen_size_increment_supplement); |
1119 return align_size_up(result, _intra_generation_alignment); | 1117 return align_size_up(result, _space_alignment); |
1120 } | 1118 } |
1121 | 1119 |
1122 size_t PSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { | 1120 size_t PSAdaptiveSizePolicy::promo_decrement_aligned_down(size_t cur_promo) { |
1123 size_t promo_heap_delta = promo_decrement(cur_promo); | 1121 size_t promo_heap_delta = promo_decrement(cur_promo); |
1124 return align_size_down(promo_heap_delta, _intra_generation_alignment); | 1122 return align_size_down(promo_heap_delta, _space_alignment); |
1125 } | 1123 } |
1126 | 1124 |
1127 size_t PSAdaptiveSizePolicy::promo_decrement(size_t cur_promo) { | 1125 size_t PSAdaptiveSizePolicy::promo_decrement(size_t cur_promo) { |
1128 size_t promo_heap_delta = promo_increment(cur_promo); | 1126 size_t promo_heap_delta = promo_increment(cur_promo); |
1129 promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor; | 1127 promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor; |
1132 | 1130 |
1133 uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( | 1131 uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( |
1134 bool is_survivor_overflow, | 1132 bool is_survivor_overflow, |
1135 uint tenuring_threshold, | 1133 uint tenuring_threshold, |
1136 size_t survivor_limit) { | 1134 size_t survivor_limit) { |
1137 assert(survivor_limit >= _intra_generation_alignment, | 1135 assert(survivor_limit >= _space_alignment, |
1138 "survivor_limit too small"); | 1136 "survivor_limit too small"); |
1139 assert((size_t)align_size_down(survivor_limit, _intra_generation_alignment) | 1137 assert((size_t)align_size_down(survivor_limit, _space_alignment) |
1140 == survivor_limit, "survivor_limit not aligned"); | 1138 == survivor_limit, "survivor_limit not aligned"); |
1141 | 1139 |
1142 // This method is called even if the tenuring threshold and survivor | 1140 // This method is called even if the tenuring threshold and survivor |
1143 // spaces are not adjusted so that the averages are sampled above. | 1141 // spaces are not adjusted so that the averages are sampled above. |
1144 if (!UsePSAdaptiveSurvivorSizePolicy || | 1142 if (!UsePSAdaptiveSurvivorSizePolicy || |
1198 // The padded average also maintains a deviation from the average; | 1196 // The padded average also maintains a deviation from the average; |
1199 // we use this to see how good of an estimate we have of what survived. | 1197 // we use this to see how good of an estimate we have of what survived. |
1200 // We're trying to pad the survivor size as little as possible without | 1198 // We're trying to pad the survivor size as little as possible without |
1201 // overflowing the survivor spaces. | 1199 // overflowing the survivor spaces. |
1202 size_t target_size = align_size_up((size_t)_avg_survived->padded_average(), | 1200 size_t target_size = align_size_up((size_t)_avg_survived->padded_average(), |
1203 _intra_generation_alignment); | 1201 _space_alignment); |
1204 target_size = MAX2(target_size, _intra_generation_alignment); | 1202 target_size = MAX2(target_size, _space_alignment); |
1205 | 1203 |
1206 if (target_size > survivor_limit) { | 1204 if (target_size > survivor_limit) { |
1207 // Target size is bigger than we can handle. Let's also reduce | 1205 // Target size is bigger than we can handle. Let's also reduce |
1208 // the tenuring threshold. | 1206 // the tenuring threshold. |
1209 target_size = survivor_limit; | 1207 target_size = survivor_limit; |