1148 return tenuring_threshold;
1149 }
1150
1151 // We'll decide whether to increase or decrease the tenuring
1152 // threshold based partly on the newly computed survivor size
1153 // (if we hit the maximum limit allowed, we'll always choose to
1154 // decrement the threshold).
1155 bool incr_tenuring_threshold = false;
1156 bool decr_tenuring_threshold = false;
1157
1158 set_decrement_tenuring_threshold_for_gc_cost(false);
1159 set_increment_tenuring_threshold_for_gc_cost(false);
1160 set_decrement_tenuring_threshold_for_survivor_limit(false);
1161
1162 if (!is_survivor_overflow) {
1163 // Keep running averages on how much survived
1164
1165 // We use the tenuring threshold to equalize the cost of major
1166 // and minor collections.
1167 // ThresholdTolerance is used to indicate how sensitive the
1168 // tenuring threshold is to differences in cost betweent the
1169 // collection types.
1170
1171 // Get the times of interest. This involves a little work, so
1172 // we cache the values here.
1173 const double major_cost = major_gc_cost();
1174 const double minor_cost = minor_gc_cost();
1175
1176 if (minor_cost > major_cost * _threshold_tolerance_percent) {
1177 // Minor times are getting too long; lower the threshold so
1178 // less survives and more is promoted.
1179 decr_tenuring_threshold = true;
1180 set_decrement_tenuring_threshold_for_gc_cost(true);
1181 } else if (major_cost > minor_cost * _threshold_tolerance_percent) {
1182 // Major times are too long, so we want less promotion.
1183 incr_tenuring_threshold = true;
1184 set_increment_tenuring_threshold_for_gc_cost(true);
1185 }
1186
1187 } else {
1188 // Survivor space overflow occurred, so promoted and survived are
1240 _avg_survived->deviation());
1241 }
1242
1243 gclog_or_tty->print( " avg_survived_padded_avg: %f",
1244 _avg_survived->padded_average());
1245
1246 if (Verbose) {
1247 gclog_or_tty->print( " avg_promoted_avg: %f"
1248 " avg_promoted_dev: %f",
1249 avg_promoted()->average(),
1250 avg_promoted()->deviation());
1251 }
1252
1253 gclog_or_tty->print( " avg_promoted_padded_avg: %f"
1254 " avg_pretenured_padded_avg: %f"
1255 " tenuring_thresh: %d"
1256 " target_size: " SIZE_FORMAT,
1257 avg_promoted()->padded_average(),
1258 _avg_pretenured->padded_average(),
1259 tenuring_threshold, target_size);
1260 tty->cr();
1261 }
1262
1263 set_survivor_size(target_size);
1264
1265 return tenuring_threshold;
1266 }
1267
1268 void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow,
1269 size_t survived,
1270 size_t promoted) {
1271 // Update averages
1272 if (!is_survivor_overflow) {
1273 // Keep running averages on how much survived
1274 _avg_survived->sample(survived);
1275 } else {
1276 size_t survived_guess = survived + promoted;
1277 _avg_survived->sample(survived_guess);
1278 }
1279 avg_promoted()->sample(promoted + _avg_pretenured->padded_average());
1280
1281 if (PrintAdaptiveSizePolicy) {
1282 gclog_or_tty->print(
1283 "AdaptiveSizePolicy::update_averages:"
1284 " survived: " SIZE_FORMAT
1285 " promoted: " SIZE_FORMAT
1286 " overflow: %s",
1287 survived, promoted, is_survivor_overflow ? "true" : "false");
1288 }
1289 }
1290
1291 bool PSAdaptiveSizePolicy::print_adaptive_size_policy_on(outputStream* st)
1292 const {
1293
1294 if (!UseAdaptiveSizePolicy) return false;
1295
1296 return AdaptiveSizePolicy::print_adaptive_size_policy_on(
1297 st,
1298 PSScavenge::tenuring_threshold());
1299 }
|
1148 return tenuring_threshold;
1149 }
1150
1151 // We'll decide whether to increase or decrease the tenuring
1152 // threshold based partly on the newly computed survivor size
1153 // (if we hit the maximum limit allowed, we'll always choose to
1154 // decrement the threshold).
1155 bool incr_tenuring_threshold = false;
1156 bool decr_tenuring_threshold = false;
1157
1158 set_decrement_tenuring_threshold_for_gc_cost(false);
1159 set_increment_tenuring_threshold_for_gc_cost(false);
1160 set_decrement_tenuring_threshold_for_survivor_limit(false);
1161
1162 if (!is_survivor_overflow) {
1163 // Keep running averages on how much survived
1164
1165 // We use the tenuring threshold to equalize the cost of major
1166 // and minor collections.
1167 // ThresholdTolerance is used to indicate how sensitive the
1168 // tenuring threshold is to differences in cost between the
1169 // collection types.
1170
1171 // Get the times of interest. This involves a little work, so
1172 // we cache the values here.
1173 const double major_cost = major_gc_cost();
1174 const double minor_cost = minor_gc_cost();
1175
1176 if (minor_cost > major_cost * _threshold_tolerance_percent) {
1177 // Minor times are getting too long; lower the threshold so
1178 // less survives and more is promoted.
1179 decr_tenuring_threshold = true;
1180 set_decrement_tenuring_threshold_for_gc_cost(true);
1181 } else if (major_cost > minor_cost * _threshold_tolerance_percent) {
1182 // Major times are too long, so we want less promotion.
1183 incr_tenuring_threshold = true;
1184 set_increment_tenuring_threshold_for_gc_cost(true);
1185 }
1186
1187 } else {
1188 // Survivor space overflow occurred, so promoted and survived are
1240 _avg_survived->deviation());
1241 }
1242
1243 gclog_or_tty->print( " avg_survived_padded_avg: %f",
1244 _avg_survived->padded_average());
1245
1246 if (Verbose) {
1247 gclog_or_tty->print( " avg_promoted_avg: %f"
1248 " avg_promoted_dev: %f",
1249 avg_promoted()->average(),
1250 avg_promoted()->deviation());
1251 }
1252
1253 gclog_or_tty->print( " avg_promoted_padded_avg: %f"
1254 " avg_pretenured_padded_avg: %f"
1255 " tenuring_thresh: %d"
1256 " target_size: " SIZE_FORMAT,
1257 avg_promoted()->padded_average(),
1258 _avg_pretenured->padded_average(),
1259 tenuring_threshold, target_size);
1260 gclog_or_tty->cr();
1261 }
1262
1263 set_survivor_size(target_size);
1264
1265 return tenuring_threshold;
1266 }
1267
1268 void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow,
1269 size_t survived,
1270 size_t promoted) {
1271 // Update averages
1272 if (!is_survivor_overflow) {
1273 // Keep running averages on how much survived
1274 _avg_survived->sample(survived);
1275 } else {
1276 size_t survived_guess = survived + promoted;
1277 _avg_survived->sample(survived_guess);
1278 }
1279 avg_promoted()->sample(promoted + _avg_pretenured->padded_average());
1280
1281 if (PrintAdaptiveSizePolicy) {
1282 gclog_or_tty->print(
1283 "AdaptiveSizePolicy::update_averages:"
1284 " survived: " SIZE_FORMAT
1285 " promoted: " SIZE_FORMAT
1286 " overflow: %s",
1287 survived, promoted, is_survivor_overflow ? "true" : "false");
1288 gclog_or_tty->cr();
1289 }
1290 }
1291
1292 bool PSAdaptiveSizePolicy::print_adaptive_size_policy_on(outputStream* st)
1293 const {
1294
1295 if (!UseAdaptiveSizePolicy) return false;
1296
1297 return AdaptiveSizePolicy::print_adaptive_size_policy_on(
1298 st,
1299 PSScavenge::tenuring_threshold());
1300 }
|