449
450 if (gc_cause != GCCause::_java_lang_system_gc ||
451 UseAdaptiveSizePolicyWithSystemGC) {
452 _latest_cms_initial_mark_start_to_end_time_secs = _STW_timer.seconds();
453 avg_initial_pause()->sample(_latest_cms_initial_mark_start_to_end_time_secs);
454
455 if (PrintAdaptiveSizePolicy && Verbose) {
456 gclog_or_tty->print(
457 "cmsAdaptiveSizePolicy::checkpoint_roots_initial_end: "
458 "initial pause: %f ", _latest_cms_initial_mark_start_to_end_time_secs);
459 }
460 }
461
462 _STW_timer.reset();
463 _STW_timer.start();
464 }
465
466 void CMSAdaptiveSizePolicy::checkpoint_roots_final_begin() {
467 _STW_timer.stop();
468 _latest_cms_initial_mark_end_to_remark_start_secs = _STW_timer.seconds();
469 // Start accumumlating time for the remark in the STW timer.
470 _STW_timer.reset();
471 _STW_timer.start();
472 }
473
474 void CMSAdaptiveSizePolicy::checkpoint_roots_final_end(
475 GCCause::Cause gc_cause) {
476 _STW_timer.stop();
477 if (gc_cause != GCCause::_java_lang_system_gc ||
478 UseAdaptiveSizePolicyWithSystemGC) {
479 // Total initial mark pause + remark pause.
480 _latest_cms_remark_start_to_end_time_secs = _STW_timer.seconds();
481 double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs +
482 _latest_cms_remark_start_to_end_time_secs;
483 double STW_time_in_ms = STW_time_in_seconds * MILLIUNITS;
484
485 avg_remark_pause()->sample(_latest_cms_remark_start_to_end_time_secs);
486
487 // Sample total for initial mark + remark
488 avg_cms_STW_time()->sample(STW_time_in_seconds);
489
520 avg_msc_interval()->sample(_latest_cms_msc_end_to_msc_start_time_secs);
521 _STW_timer.reset();
522 _STW_timer.start();
523 }
524
525 void CMSAdaptiveSizePolicy::msc_collection_end(GCCause::Cause gc_cause) {
526 if (PrintAdaptiveSizePolicy && Verbose) {
527 gclog_or_tty->print(" ");
528 gclog_or_tty->stamp();
529 gclog_or_tty->print(": msc_collection_end ");
530 }
531 _STW_timer.stop();
532 if (gc_cause != GCCause::_java_lang_system_gc ||
533 UseAdaptiveSizePolicyWithSystemGC) {
534 double msc_pause_in_seconds = _STW_timer.seconds();
535 if ((_latest_cms_msc_end_to_msc_start_time_secs > 0.0) &&
536 (msc_pause_in_seconds > 0.0)) {
537 avg_msc_pause()->sample(msc_pause_in_seconds);
538 double mutator_time_in_seconds = 0.0;
539 if (_latest_cms_collection_end_to_collection_start_secs == 0.0) {
540 // This assertion may fail because of time stamp gradularity.
541 // Comment it out and investiage it at a later time. The large
542 // time stamp granularity occurs on some older linux systems.
543 #ifndef CLOCK_GRANULARITY_TOO_LARGE
544 assert((_latest_cms_concurrent_marking_time_secs == 0.0) &&
545 (_latest_cms_concurrent_precleaning_time_secs == 0.0) &&
546 (_latest_cms_concurrent_sweeping_time_secs == 0.0),
547 "There should not be any concurrent time");
548 #endif
549 // A concurrent collection did not start. Mutator time
550 // between collections comes from the STW MSC timer.
551 mutator_time_in_seconds = _latest_cms_msc_end_to_msc_start_time_secs;
552 } else {
553 // The concurrent collection did start so count the mutator
554 // time to the start of the concurrent collection. In this
555 // case the _latest_cms_msc_end_to_msc_start_time_secs measures
556 // the time between the initial mark or remark and the
557 // start of the MSC. That has no real meaning.
558 mutator_time_in_seconds = _latest_cms_collection_end_to_collection_start_secs;
559 }
560
561 double latest_cms_sum_concurrent_phases_time_secs =
819 double time_since_STW_gc = _STW_timer.seconds();
820 _STW_timer.start();
821
822 return MIN2(time_since_cms_gc, time_since_STW_gc);
823 }
824
825 double CMSAdaptiveSizePolicy::major_gc_interval_average_for_decay() const {
826 double cms_interval = _avg_concurrent_interval->average();
827 double msc_interval = _avg_msc_interval->average();
828 double ms_interval = _avg_ms_interval->average();
829
830 return MAX3(cms_interval, msc_interval, ms_interval);
831 }
832
833 double CMSAdaptiveSizePolicy::cms_gc_cost() const {
834 return avg_major_gc_cost()->average();
835 }
836
837 void CMSAdaptiveSizePolicy::ms_collection_marking_begin() {
838 _STW_timer.stop();
839 // Start accumumlating time for the marking in the STW timer.
840 _STW_timer.reset();
841 _STW_timer.start();
842 }
843
844 void CMSAdaptiveSizePolicy::ms_collection_marking_end(
845 GCCause::Cause gc_cause) {
846 _STW_timer.stop();
847 if (gc_cause != GCCause::_java_lang_system_gc ||
848 UseAdaptiveSizePolicyWithSystemGC) {
849 _latest_cms_ms_marking_start_to_end_time_secs = _STW_timer.seconds();
850 if (PrintAdaptiveSizePolicy && Verbose) {
851 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::"
852 "msc_collection_marking_end: mutator time %f",
853 _latest_cms_ms_marking_start_to_end_time_secs);
854 }
855 }
856 _STW_timer.reset();
857 _STW_timer.start();
858 }
859
1210 return tenuring_threshold;
1211 }
1212
1213 // We'll decide whether to increase or decrease the tenuring
1214 // threshold based partly on the newly computed survivor size
1215 // (if we hit the maximum limit allowed, we'll always choose to
1216 // decrement the threshold).
1217 bool incr_tenuring_threshold = false;
1218 bool decr_tenuring_threshold = false;
1219
1220 set_decrement_tenuring_threshold_for_gc_cost(false);
1221 set_increment_tenuring_threshold_for_gc_cost(false);
1222 set_decrement_tenuring_threshold_for_survivor_limit(false);
1223
1224 if (!is_survivor_overflow) {
1225 // Keep running averages on how much survived
1226
1227 // We use the tenuring threshold to equalize the cost of major
1228 // and minor collections.
1229 // ThresholdTolerance is used to indicate how sensitive the
1230 // tenuring threshold is to differences in cost betweent the
1231 // collection types.
1232
1233 // Get the times of interest. This involves a little work, so
1234 // we cache the values here.
1235 const double major_cost = major_gc_cost();
1236 const double minor_cost = minor_gc_cost();
1237
1238 if (minor_cost > major_cost * _threshold_tolerance_percent) {
1239 // Minor times are getting too long; lower the threshold so
1240 // less survives and more is promoted.
1241 decr_tenuring_threshold = true;
1242 set_decrement_tenuring_threshold_for_gc_cost(true);
1243 } else if (major_cost > minor_cost * _threshold_tolerance_percent) {
1244 // Major times are too long, so we want less promotion.
1245 incr_tenuring_threshold = true;
1246 set_increment_tenuring_threshold_for_gc_cost(true);
1247 }
1248
1249 } else {
1250 // Survivor space overflow occurred, so promoted and survived are
|
449
450 if (gc_cause != GCCause::_java_lang_system_gc ||
451 UseAdaptiveSizePolicyWithSystemGC) {
452 _latest_cms_initial_mark_start_to_end_time_secs = _STW_timer.seconds();
453 avg_initial_pause()->sample(_latest_cms_initial_mark_start_to_end_time_secs);
454
455 if (PrintAdaptiveSizePolicy && Verbose) {
456 gclog_or_tty->print(
457 "cmsAdaptiveSizePolicy::checkpoint_roots_initial_end: "
458 "initial pause: %f ", _latest_cms_initial_mark_start_to_end_time_secs);
459 }
460 }
461
462 _STW_timer.reset();
463 _STW_timer.start();
464 }
465
466 void CMSAdaptiveSizePolicy::checkpoint_roots_final_begin() {
467 _STW_timer.stop();
468 _latest_cms_initial_mark_end_to_remark_start_secs = _STW_timer.seconds();
469 // Start accumulating time for the remark in the STW timer.
470 _STW_timer.reset();
471 _STW_timer.start();
472 }
473
474 void CMSAdaptiveSizePolicy::checkpoint_roots_final_end(
475 GCCause::Cause gc_cause) {
476 _STW_timer.stop();
477 if (gc_cause != GCCause::_java_lang_system_gc ||
478 UseAdaptiveSizePolicyWithSystemGC) {
479 // Total initial mark pause + remark pause.
480 _latest_cms_remark_start_to_end_time_secs = _STW_timer.seconds();
481 double STW_time_in_seconds = _latest_cms_initial_mark_start_to_end_time_secs +
482 _latest_cms_remark_start_to_end_time_secs;
483 double STW_time_in_ms = STW_time_in_seconds * MILLIUNITS;
484
485 avg_remark_pause()->sample(_latest_cms_remark_start_to_end_time_secs);
486
487 // Sample total for initial mark + remark
488 avg_cms_STW_time()->sample(STW_time_in_seconds);
489
520 avg_msc_interval()->sample(_latest_cms_msc_end_to_msc_start_time_secs);
521 _STW_timer.reset();
522 _STW_timer.start();
523 }
524
525 void CMSAdaptiveSizePolicy::msc_collection_end(GCCause::Cause gc_cause) {
526 if (PrintAdaptiveSizePolicy && Verbose) {
527 gclog_or_tty->print(" ");
528 gclog_or_tty->stamp();
529 gclog_or_tty->print(": msc_collection_end ");
530 }
531 _STW_timer.stop();
532 if (gc_cause != GCCause::_java_lang_system_gc ||
533 UseAdaptiveSizePolicyWithSystemGC) {
534 double msc_pause_in_seconds = _STW_timer.seconds();
535 if ((_latest_cms_msc_end_to_msc_start_time_secs > 0.0) &&
536 (msc_pause_in_seconds > 0.0)) {
537 avg_msc_pause()->sample(msc_pause_in_seconds);
538 double mutator_time_in_seconds = 0.0;
539 if (_latest_cms_collection_end_to_collection_start_secs == 0.0) {
540 // This assertion may fail because of time stamp granularity.
541 // Comment it out and investigate it at a later time. The large
542 // time stamp granularity occurs on some older linux systems.
543 #ifndef CLOCK_GRANULARITY_TOO_LARGE
544 assert((_latest_cms_concurrent_marking_time_secs == 0.0) &&
545 (_latest_cms_concurrent_precleaning_time_secs == 0.0) &&
546 (_latest_cms_concurrent_sweeping_time_secs == 0.0),
547 "There should not be any concurrent time");
548 #endif
549 // A concurrent collection did not start. Mutator time
550 // between collections comes from the STW MSC timer.
551 mutator_time_in_seconds = _latest_cms_msc_end_to_msc_start_time_secs;
552 } else {
553 // The concurrent collection did start so count the mutator
554 // time to the start of the concurrent collection. In this
555 // case the _latest_cms_msc_end_to_msc_start_time_secs measures
556 // the time between the initial mark or remark and the
557 // start of the MSC. That has no real meaning.
558 mutator_time_in_seconds = _latest_cms_collection_end_to_collection_start_secs;
559 }
560
561 double latest_cms_sum_concurrent_phases_time_secs =
819 double time_since_STW_gc = _STW_timer.seconds();
820 _STW_timer.start();
821
822 return MIN2(time_since_cms_gc, time_since_STW_gc);
823 }
824
825 double CMSAdaptiveSizePolicy::major_gc_interval_average_for_decay() const {
826 double cms_interval = _avg_concurrent_interval->average();
827 double msc_interval = _avg_msc_interval->average();
828 double ms_interval = _avg_ms_interval->average();
829
830 return MAX3(cms_interval, msc_interval, ms_interval);
831 }
832
833 double CMSAdaptiveSizePolicy::cms_gc_cost() const {
834 return avg_major_gc_cost()->average();
835 }
836
837 void CMSAdaptiveSizePolicy::ms_collection_marking_begin() {
838 _STW_timer.stop();
839 // Start accumulating time for the marking in the STW timer.
840 _STW_timer.reset();
841 _STW_timer.start();
842 }
843
844 void CMSAdaptiveSizePolicy::ms_collection_marking_end(
845 GCCause::Cause gc_cause) {
846 _STW_timer.stop();
847 if (gc_cause != GCCause::_java_lang_system_gc ||
848 UseAdaptiveSizePolicyWithSystemGC) {
849 _latest_cms_ms_marking_start_to_end_time_secs = _STW_timer.seconds();
850 if (PrintAdaptiveSizePolicy && Verbose) {
851 gclog_or_tty->print_cr("CMSAdaptiveSizePolicy::"
852 "msc_collection_marking_end: mutator time %f",
853 _latest_cms_ms_marking_start_to_end_time_secs);
854 }
855 }
856 _STW_timer.reset();
857 _STW_timer.start();
858 }
859
1210 return tenuring_threshold;
1211 }
1212
1213 // We'll decide whether to increase or decrease the tenuring
1214 // threshold based partly on the newly computed survivor size
1215 // (if we hit the maximum limit allowed, we'll always choose to
1216 // decrement the threshold).
1217 bool incr_tenuring_threshold = false;
1218 bool decr_tenuring_threshold = false;
1219
1220 set_decrement_tenuring_threshold_for_gc_cost(false);
1221 set_increment_tenuring_threshold_for_gc_cost(false);
1222 set_decrement_tenuring_threshold_for_survivor_limit(false);
1223
1224 if (!is_survivor_overflow) {
1225 // Keep running averages on how much survived
1226
1227 // We use the tenuring threshold to equalize the cost of major
1228 // and minor collections.
1229 // ThresholdTolerance is used to indicate how sensitive the
1230 // tenuring threshold is to differences in cost between the
1231 // collection types.
1232
1233 // Get the times of interest. This involves a little work, so
1234 // we cache the values here.
1235 const double major_cost = major_gc_cost();
1236 const double minor_cost = minor_gc_cost();
1237
1238 if (minor_cost > major_cost * _threshold_tolerance_percent) {
1239 // Minor times are getting too long; lower the threshold so
1240 // less survives and more is promoted.
1241 decr_tenuring_threshold = true;
1242 set_decrement_tenuring_threshold_for_gc_cost(true);
1243 } else if (major_cost > minor_cost * _threshold_tolerance_percent) {
1244 // Major times are too long, so we want less promotion.
1245 incr_tenuring_threshold = true;
1246 set_increment_tenuring_threshold_for_gc_cost(true);
1247 }
1248
1249 } else {
1250 // Survivor space overflow occurred, so promoted and survived are
|