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

Print this page

        

@@ -1612,46 +1612,33 @@
                                          _g1->workers()->active_workers(),
                                          HeapRegion::InitialClaimValue);
   }
 };
 
+uint G1CollectorPolicy::calculate_parallel_work_chunk_size(int n_workers, uint n_regions) {
+  assert(n_workers > 0, "The active gc workers should be greater than 0");
+  const uint overpartition_factor = 4;
+  const uint min_chunk_size = MAX2(n_regions / n_workers, 1U);
+  return MAX2(n_regions / (n_workers * overpartition_factor), min_chunk_size);
+}
+
 void
-G1CollectorPolicy::record_concurrent_mark_cleanup_end(int no_of_gc_threads) {
+G1CollectorPolicy::record_concurrent_mark_cleanup_end(int n_workers) {
   _collectionSetChooser->clear();
 
-  uint region_num = _g1->n_regions();
   if (G1CollectedHeap::use_parallel_gc_threads()) {
-    const uint OverpartitionFactor = 4;
-    uint WorkUnit;
-    // The use of MinChunkSize = 8 in the original code
-    // causes some assertion failures when the total number of
-    // region is less than 8.  The code here tries to fix that.
-    // Should the original code also be fixed?
-    if (no_of_gc_threads > 0) {
-      const uint MinWorkUnit = MAX2(region_num / no_of_gc_threads, 1U);
-      WorkUnit = MAX2(region_num / (no_of_gc_threads * OverpartitionFactor),
-                      MinWorkUnit);
-    } else {
-      assert(no_of_gc_threads > 0,
-        "The active gc workers should be greater than 0");
-      // In a product build do something reasonable to avoid a crash.
-      const uint MinWorkUnit = MAX2(region_num / (uint) ParallelGCThreads, 1U);
-      WorkUnit =
-        MAX2(region_num / (uint) (ParallelGCThreads * OverpartitionFactor),
-             MinWorkUnit);
-    }
-    _collectionSetChooser->prepare_for_par_region_addition(_g1->n_regions(),
-                                                           WorkUnit);
-    ParKnownGarbageTask parKnownGarbageTask(_collectionSetChooser,
-                                            (int) WorkUnit);
-    _g1->workers()->run_task(&parKnownGarbageTask);
+    uint n_regions = _g1->n_regions();
+    uint chunk_size = calculate_parallel_work_chunk_size(n_workers, n_regions);
+    _collectionSetChooser->prepare_for_par_region_addition(n_regions, chunk_size);
+    ParKnownGarbageTask par_known_garbage_task(_collectionSetChooser, chunk_size);
+    _g1->workers()->run_task(&par_known_garbage_task);
 
     assert(_g1->check_heap_region_claim_values(HeapRegion::InitialClaimValue),
            "sanity check");
   } else {
-    KnownGarbageClosure knownGarbagecl(_collectionSetChooser);
-    _g1->heap_region_iterate(&knownGarbagecl);
+    KnownGarbageClosure known_garbage_closure(_collectionSetChooser);
+    _g1->heap_region_iterate(&known_garbage_closure);
   }
 
   _collectionSetChooser->sort_regions();
 
   double end_sec = os::elapsedTime();