< prev index next >

src/share/vm/gc/g1/g1CollectedHeap.cpp

Print this page




3850   }
3851 
3852   if (G1Log::finer()) {
3853     if (evacuation_failed()) {
3854       gclog_or_tty->print(" (to-space exhausted)");
3855     }
3856     gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec);
3857     g1_policy()->phase_times()->note_gc_end();
3858     g1_policy()->phase_times()->print(pause_time_sec);
3859     g1_policy()->print_detailed_heap_transition();
3860   } else {
3861     if (evacuation_failed()) {
3862       gclog_or_tty->print("--");
3863     }
3864     g1_policy()->print_heap_transition();
3865     gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec);
3866   }
3867   gclog_or_tty->flush();
3868 }
3869 















3870 bool
3871 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
3872   assert_at_safepoint(true /* should_be_vm_thread */);
3873   guarantee(!is_gc_active(), "collection is not reentrant");
3874 
3875   if (GC_locker::check_active_before_gc()) {
3876     return false;
3877   }
3878 
3879   _gc_timer_stw->register_gc_start();
3880 
3881   _gc_tracer_stw->report_gc_start(gc_cause(), _gc_timer_stw->gc_start());
3882 
3883   SvcGCMarker sgcm(SvcGCMarker::MINOR);
3884   ResourceMark rm;
3885 


3886   G1Log::update_level();
3887   print_heap_before_gc();
3888   trace_heap_before_gc(_gc_tracer_stw);
3889 
3890   verify_region_sets_optional();
3891   verify_dirty_young_regions();
3892 
3893   // This call will decide whether this pause is an initial-mark
3894   // pause. If it is, during_initial_mark_pause() will return true
3895   // for the duration of this pause.
3896   g1_policy()->decide_on_conc_mark_initiation();
3897 
3898   // We do not allow initial-mark to be piggy-backed on a mixed GC.
3899   assert(!collector_state()->during_initial_mark_pause() ||
3900           collector_state()->gcs_are_young(), "sanity");
3901 
3902   // We also do not allow mixed GCs during marking.
3903   assert(!collector_state()->mark_in_progress() || collector_state()->gcs_are_young(), "sanity");
3904 
3905   // Record whether this pause is an initial mark. When the current


3986         // before the start GC event.
3987         _hr_printer.start_gc(false /* full */, (size_t) total_collections());
3988 
3989         // This timing is only used by the ergonomics to handle our pause target.
3990         // It is unclear why this should not include the full pause. We will
3991         // investigate this in CR 7178365.
3992         //
3993         // Preserving the old comment here if that helps the investigation:
3994         //
3995         // The elapsed time induced by the start time below deliberately elides
3996         // the possible verification above.
3997         double sample_start_time_sec = os::elapsedTime();
3998 
3999 #if YOUNG_LIST_VERBOSE
4000         gclog_or_tty->print_cr("\nBefore recording pause start.\nYoung_list:");
4001         _young_list->print();
4002         g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
4003 #endif // YOUNG_LIST_VERBOSE
4004 
4005         g1_policy()->record_collection_pause_start(sample_start_time_sec);
4006 
4007         double scan_wait_start = os::elapsedTime();
4008         // We have to wait until the CM threads finish scanning the
4009         // root regions as it's the only way to ensure that all the
4010         // objects on them have been correctly scanned before we start
4011         // moving them during the GC.
4012         bool waited = _cm->root_regions()->wait_until_scan_finished();
4013         double wait_time_ms = 0.0;
4014         if (waited) {
4015           double scan_wait_end = os::elapsedTime();
4016           wait_time_ms = (scan_wait_end - scan_wait_start) * 1000.0;
4017         }
4018         g1_policy()->phase_times()->record_root_region_scan_wait_time(wait_time_ms);
4019 
4020 #if YOUNG_LIST_VERBOSE
4021         gclog_or_tty->print_cr("\nAfter recording pause start.\nYoung_list:");
4022         _young_list->print();
4023 #endif // YOUNG_LIST_VERBOSE
4024 
4025         if (collector_state()->during_initial_mark_pause()) {
4026           concurrent_mark()->checkpointRootsInitialPre();
4027         }
4028 
4029 #if YOUNG_LIST_VERBOSE
4030         gclog_or_tty->print_cr("\nBefore choosing collection set.\nYoung_list:");
4031         _young_list->print();
4032         g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
4033 #endif // YOUNG_LIST_VERBOSE
4034 
4035         g1_policy()->finalize_cset(target_pause_time_ms, evacuation_info);
4036 
4037         register_humongous_regions_with_cset();
4038 




3850   }
3851 
3852   if (G1Log::finer()) {
3853     if (evacuation_failed()) {
3854       gclog_or_tty->print(" (to-space exhausted)");
3855     }
3856     gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec);
3857     g1_policy()->phase_times()->note_gc_end();
3858     g1_policy()->phase_times()->print(pause_time_sec);
3859     g1_policy()->print_detailed_heap_transition();
3860   } else {
3861     if (evacuation_failed()) {
3862       gclog_or_tty->print("--");
3863     }
3864     g1_policy()->print_heap_transition();
3865     gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec);
3866   }
3867   gclog_or_tty->flush();
3868 }
3869 
3870 void G1CollectedHeap::wait_for_root_region_scanning() {
3871   double scan_wait_start = os::elapsedTime();
3872   // We have to wait until the CM threads finish scanning the
3873   // root regions as it's the only way to ensure that all the
3874   // objects on them have been correctly scanned before we start
3875   // moving them during the GC.
3876   bool waited = _cm->root_regions()->wait_until_scan_finished();
3877   double wait_time_ms = 0.0;
3878   if (waited) {
3879     double scan_wait_end = os::elapsedTime();
3880     wait_time_ms = (scan_wait_end - scan_wait_start) * 1000.0;
3881   }
3882   g1_policy()->phase_times()->record_root_region_scan_wait_time(wait_time_ms);
3883 }
3884 
3885 bool
3886 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
3887   assert_at_safepoint(true /* should_be_vm_thread */);
3888   guarantee(!is_gc_active(), "collection is not reentrant");
3889 
3890   if (GC_locker::check_active_before_gc()) {
3891     return false;
3892   }
3893 
3894   _gc_timer_stw->register_gc_start();
3895 
3896   _gc_tracer_stw->report_gc_start(gc_cause(), _gc_timer_stw->gc_start());
3897 
3898   SvcGCMarker sgcm(SvcGCMarker::MINOR);
3899   ResourceMark rm;
3900 
3901   wait_for_root_region_scanning();
3902 
3903   G1Log::update_level();
3904   print_heap_before_gc();
3905   trace_heap_before_gc(_gc_tracer_stw);
3906 
3907   verify_region_sets_optional();
3908   verify_dirty_young_regions();
3909 
3910   // This call will decide whether this pause is an initial-mark
3911   // pause. If it is, during_initial_mark_pause() will return true
3912   // for the duration of this pause.
3913   g1_policy()->decide_on_conc_mark_initiation();
3914 
3915   // We do not allow initial-mark to be piggy-backed on a mixed GC.
3916   assert(!collector_state()->during_initial_mark_pause() ||
3917           collector_state()->gcs_are_young(), "sanity");
3918 
3919   // We also do not allow mixed GCs during marking.
3920   assert(!collector_state()->mark_in_progress() || collector_state()->gcs_are_young(), "sanity");
3921 
3922   // Record whether this pause is an initial mark. When the current


4003         // before the start GC event.
4004         _hr_printer.start_gc(false /* full */, (size_t) total_collections());
4005 
4006         // This timing is only used by the ergonomics to handle our pause target.
4007         // It is unclear why this should not include the full pause. We will
4008         // investigate this in CR 7178365.
4009         //
4010         // Preserving the old comment here if that helps the investigation:
4011         //
4012         // The elapsed time induced by the start time below deliberately elides
4013         // the possible verification above.
4014         double sample_start_time_sec = os::elapsedTime();
4015 
4016 #if YOUNG_LIST_VERBOSE
4017         gclog_or_tty->print_cr("\nBefore recording pause start.\nYoung_list:");
4018         _young_list->print();
4019         g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
4020 #endif // YOUNG_LIST_VERBOSE
4021 
4022         g1_policy()->record_collection_pause_start(sample_start_time_sec);













4023 
4024 #if YOUNG_LIST_VERBOSE
4025         gclog_or_tty->print_cr("\nAfter recording pause start.\nYoung_list:");
4026         _young_list->print();
4027 #endif // YOUNG_LIST_VERBOSE
4028 
4029         if (collector_state()->during_initial_mark_pause()) {
4030           concurrent_mark()->checkpointRootsInitialPre();
4031         }
4032 
4033 #if YOUNG_LIST_VERBOSE
4034         gclog_or_tty->print_cr("\nBefore choosing collection set.\nYoung_list:");
4035         _young_list->print();
4036         g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
4037 #endif // YOUNG_LIST_VERBOSE
4038 
4039         g1_policy()->finalize_cset(target_pause_time_ms, evacuation_info);
4040 
4041         register_humongous_regions_with_cset();
4042 


< prev index next >