src/hotspot/share/gc/z/zWorkers.cpp
changeset 59150 82b2ba888190
parent 59149 3b998574be4b
equal deleted inserted replaced
59149:3b998574be4b 59150:82b2ba888190
    24 #include "precompiled.hpp"
    24 #include "precompiled.hpp"
    25 #include "gc/z/zGlobals.hpp"
    25 #include "gc/z/zGlobals.hpp"
    26 #include "gc/z/zTask.hpp"
    26 #include "gc/z/zTask.hpp"
    27 #include "gc/z/zThread.hpp"
    27 #include "gc/z/zThread.hpp"
    28 #include "gc/z/zWorkers.inline.hpp"
    28 #include "gc/z/zWorkers.inline.hpp"
    29 #include "runtime/os.hpp"
       
    30 #include "runtime/mutexLocker.hpp"
    29 #include "runtime/mutexLocker.hpp"
    31 #include "runtime/safepoint.hpp"
    30 #include "runtime/safepoint.hpp"
    32 
       
    33 static uint calculate_nworkers_based_on_ncpus(double cpu_share_in_percent) {
       
    34   return ceil(os::initial_active_processor_count() * cpu_share_in_percent / 100.0);
       
    35 }
       
    36 
       
    37 static uint calculate_nworkers_based_on_heap_size(double reserve_share_in_percent) {
       
    38   const int nworkers = (MaxHeapSize * (reserve_share_in_percent / 100.0)) / ZPageSizeSmall;
       
    39   return MAX2(nworkers, 1);
       
    40 }
       
    41 
       
    42 static uint calculate_nworkers(double cpu_share_in_percent) {
       
    43   // Cap number of workers so that we don't use more than 2% of the max heap
       
    44   // for the small page reserve. This is useful when using small heaps on
       
    45   // large machines.
       
    46   return MIN2(calculate_nworkers_based_on_ncpus(cpu_share_in_percent),
       
    47               calculate_nworkers_based_on_heap_size(2.0));
       
    48 }
       
    49 
       
    50 uint ZWorkers::calculate_nparallel() {
       
    51   // Use 60% of the CPUs, rounded up. We would like to use as many threads as
       
    52   // possible to increase parallelism. However, using a thread count that is
       
    53   // close to the number of processors tends to lead to over-provisioning and
       
    54   // scheduling latency issues. Using 60% of the active processors appears to
       
    55   // be a fairly good balance.
       
    56   return calculate_nworkers(60.0);
       
    57 }
       
    58 
       
    59 uint ZWorkers::calculate_nconcurrent() {
       
    60   // Use 12.5% of the CPUs, rounded up. The number of concurrent threads we
       
    61   // would like to use heavily depends on the type of workload we are running.
       
    62   // Using too many threads will have a negative impact on the application
       
    63   // throughput, while using too few threads will prolong the GC-cycle and
       
    64   // we then risk being out-run by the application. Using 12.5% of the active
       
    65   // processors appears to be a fairly good balance.
       
    66   return calculate_nworkers(12.5);
       
    67 }
       
    68 
    31 
    69 class ZWorkersInitializeTask : public ZTask {
    32 class ZWorkersInitializeTask : public ZTask {
    70 private:
    33 private:
    71   const uint _nworkers;
    34   const uint _nworkers;
    72   uint       _started;
    35   uint       _started;