RFR: 8080837: Move number of workers calculation out of CollectionSetChooser::prepare_for_par_region_addition

Stefan Karlsson stefan.karlsson at oracle.com
Thu May 21 13:03:50 UTC 2015

Hi all,

Please, review this patch to move the code to determine the number of 
used workers out of 
CollectionSetChooser::prepare_for_par_region_addition and up to 
G1CollectorPolicy::record_concurrent_mark_cleanup_end, where the worker 
threads are started.


The patch also remove the redundant calculation of n_threads:

-  uint n_threads = (uint) ParallelGCThreads;
-  if (UseDynamicNumberOfGCThreads) {
-    assert(G1CollectedHeap::heap()->workers()->active_workers() > 0,
-      "Should have been set earlier");
-    // This is defensive code. As the assertion above says, the number
-    // of active threads should be > 0, but in case there is some path
-    // or some improperly initialized variable with leads to no
-    // active threads, protect against that in a product build.
-    n_threads = MAX2(G1CollectedHeap::heap()->workers()->active_workers(),
-                     1U);
-  }

since that logic is already present in the setup code of G1's 
   _workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads,
                           /* are_GC_task_threads */true,
                           /* are_ConcurrentGC_threads */false);

and FlexibleWorkGang::set_active_workers:
   void set_active_workers(uint v) {
     assert(v <= _total_workers,
            "Trying to set more workers active than there are");
     _active_workers = MIN2(v, _total_workers);
     assert(v != 0, "Trying to set active workers to 0");
     _active_workers = MAX2(1U, _active_workers);
     assert(UseDynamicNumberOfGCThreads || _active_workers == 
            "Unless dynamic should use total workers");

which is called at the previous collection pause.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20150521/922275a8/attachment.html>

More information about the hotspot-gc-dev mailing list