--- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-02-17 09:48:38.906441612 +0100 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-02-17 09:48:38.838439637 +0100 @@ -351,6 +351,23 @@ gclog_or_tty->cr(); } +static const char* g1_ext_root_task_strings[G1CollectedHeap::G1H_PS_NumElements] = { + "Filter SATB Roots (ms)", + "CM RefProcessor Roots (ms)", + "Wait For Strong CLD (ms)", + "Weak CLD Roots (ms)" +}; + +const char* G1CollectedHeap::ext_roots_task_string(uint i) { + vmassert(i < num_ext_root_tasks(), "must be"); + if (i < SH_PS_NumElements) { + return SharedHeap::ext_roots_task_str(i); + } else { + return g1_ext_root_task_strings[i - SharedHeap::SH_PS_NumElements]; + } +} + + void G1RegionMappingChangedListener::reset_from_card_cache(uint start_idx, size_t num_regions) { HeapRegionRemSet::invalidate_from_card_cache(start_idx, num_regions); } @@ -4552,6 +4569,9 @@ G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, &pss); + G1GCPhaseTimes* pt = _g1h->g1_policy()->phase_times(); + GCPhaseTimeTracker phase_tracker(pt->get_ext_root_scan_phase_times(), pt->num_ext_root_scan_phases(), worker_id); + pss.start_strong_roots(); _g1h->g1_process_roots(strong_root_cl, weak_root_cl, @@ -4559,7 +4579,8 @@ strong_cld_cl, weak_cld_cl, strong_code_cl, - worker_id); + worker_id, + &phase_tracker); pss.end_strong_roots(); @@ -4604,7 +4625,8 @@ CLDClosure* scan_strong_clds, CLDClosure* scan_weak_clds, CodeBlobClosure* scan_strong_code, - uint worker_i) { + uint worker_i, + GCPhaseTimeTracker* phase_tracker) { // First scan the shared roots. double ext_roots_start = os::elapsedTime(); @@ -4623,24 +4645,36 @@ scan_strong_clds, // Unloading Initial Marks handle the weak CLDs separately. (trace_metadata ? NULL : scan_weak_clds), - scan_strong_code); + scan_strong_code, + phase_tracker); // Now the CM ref_processor roots. - if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) { - // We need to treat the discovered reference lists of the - // concurrent mark ref processor as roots and keep entries - // (which are added by the marking threads) on them live - // until they can be processed at the end of marking. - ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots); + { + TrackPhaseTime x(phase_tracker, SharedHeap::SH_PS_NumElements + G1H_PS_refProcessor_oops_do); + if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) { + // We need to treat the discovered reference lists of the + // concurrent mark ref processor as roots and keep entries + // (which are added by the marking threads) on them live + // until they can be processed at the end of marking. + ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots); + } } - if (trace_metadata) { - // Barrier to make sure all workers passed - // the strong CLD and strong nmethods phases. - active_strong_roots_scope()->wait_until_all_workers_done_with_threads(n_par_threads()); + { + TrackPhaseTime x(phase_tracker, SharedHeap::SH_PS_NumElements + G1H_PS_wait_strong_cld_nmethods); + if (trace_metadata) { + // Barrier to make sure all workers passed + // the strong CLD and strong nmethods phases. + active_strong_roots_scope()->wait_until_all_workers_done_with_threads(n_par_threads()); + } + } - // Now take the complement of the strong CLDs. - ClassLoaderDataGraph::roots_cld_do(NULL, scan_weak_clds); + { + TrackPhaseTime x(phase_tracker, SharedHeap::SH_PS_NumElements + G1H_PS_weak_clds_oops_do); + if (trace_metadata) { + // Now take the complement of the strong CLDs. + ClassLoaderDataGraph::roots_cld_do(NULL, scan_weak_clds); + } } // Finish up any enqueued closure apps (attributed as object copy time). @@ -4661,13 +4695,16 @@ // to make sure we remove any oops into the CSet (which will show up // as implicitly live). double satb_filtering_ms = 0.0; - if (!_process_strong_tasks->is_task_claimed(G1H_PS_filter_satb_buffers)) { - if (mark_in_progress()) { - double satb_filter_start = os::elapsedTime(); + { + TrackPhaseTime x(phase_tracker, SharedHeap::SH_PS_NumElements + G1H_PS_filter_satb_buffers); + if (!_process_strong_tasks->is_task_claimed(G1H_PS_filter_satb_buffers)) { + if (mark_in_progress()) { + double satb_filter_start = os::elapsedTime(); - JavaThread::satb_mark_queue_set().filter_thread_buffers(); + JavaThread::satb_mark_queue_set().filter_thread_buffers(); - satb_filtering_ms = (os::elapsedTime() - satb_filter_start) * 1000.0; + satb_filtering_ms = (os::elapsedTime() - satb_filter_start) * 1000.0; + } } } g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);