18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/z/zGlobals.hpp" 26 #include "gc/z/zTask.hpp" 27 #include "gc/z/zThread.hpp" 28 #include "gc/z/zWorkers.inline.hpp" 29 #include "runtime/os.hpp" 30 #include "runtime/mutexLocker.hpp" 31 #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)) - ZPageSizeMedium) / 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 never use more than 10% of the max heap 44 // for the reserve. This is useful when using small heaps on large machines. 45 return MIN2(calculate_nworkers_based_on_ncpus(cpu_share_in_percent), 46 calculate_nworkers_based_on_heap_size(10.0)); 47 } 48 49 uint ZWorkers::calculate_nparallel() { 50 // Use 60% of the CPUs, rounded up. We would like to use as many threads as 51 // possible to increase parallelism. However, using a thread count that is 52 // close to the number of processors tends to lead to over-provisioning and 53 // scheduling latency issues. Using 60% of the active processors appears to 54 // be a fairly good balance. 55 return calculate_nworkers(60.0); 56 } 57 58 uint ZWorkers::calculate_nconcurrent() { 59 // Use 12.5% of the CPUs, rounded up. The number of concurrent threads we 60 // would like to use heavily depends on the type of workload we are running. 61 // Using too many threads will have a negative impact on the application 62 // throughput, while using too few threads will prolong the GC-cycle and 63 // we then risk being out-run by the application. Using 12.5% of the active 64 // processors appears to be a fairly good balance. 65 return calculate_nworkers(12.5); 66 } | 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/z/zGlobals.hpp" 26 #include "gc/z/zTask.hpp" 27 #include "gc/z/zThread.hpp" 28 #include "gc/z/zWorkers.inline.hpp" 29 #include "runtime/os.hpp" 30 #include "runtime/mutexLocker.hpp" 31 #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 } |