< prev index next >

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

Print this page
rev 7854 : imported patch 8027962-per-phase-timing-measurements-for-strong-roots-processing

@@ -349,10 +349,27 @@
   }
 
   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);
 }
 
 void G1RegionMappingChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {

@@ -4550,18 +4567,22 @@
       }
 
 
       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,
                              &push_heap_rs_cl,
                              strong_cld_cl,
                              weak_cld_cl,
                              strong_code_cl,
-                             worker_id);
+                             worker_id,
+                             &phase_tracker);
 
       pss.end_strong_roots();
 
       {
         double start = os::elapsedTime();

@@ -4602,11 +4623,12 @@
                  OopClosure* scan_non_heap_weak_roots,
                  G1ParPushHeapRSClosure* scan_rs,
                  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();
   double closure_app_time_sec = 0.0;
 

@@ -4621,29 +4643,41 @@
                 &buf_scan_non_heap_roots,
                 &buf_scan_non_heap_weak_roots,
                 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.
+  {
+    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);
   }
+  }
 
+  {
+    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());
+    }
+  }
 
+  {
+    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).
   buf_scan_non_heap_roots.done();
   buf_scan_non_heap_weak_roots.done();
 

@@ -4659,19 +4693,22 @@
 
   // During conc marking we have to filter the per-thread SATB buffers
   // to make sure we remove any oops into the CSet (which will show up
   // as implicitly live).
   double satb_filtering_ms = 0.0;
+  {
+    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();
 
       satb_filtering_ms = (os::elapsedTime() - satb_filter_start) * 1000.0;
     }
   }
+  }
   g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);
 
   // Now scan the complement of the collection set.
   G1CodeBlobClosure scavenge_cs_nmethods(scan_non_heap_weak_roots);
 
< prev index next >