src/share/vm/runtime/vm_version.cpp

changeset 445
28372612af5e
parent 435
a61af66fc99e
child 631
d1605aabd0a1
     1.1 --- a/src/share/vm/runtime/vm_version.cpp	Thu Feb 21 11:03:54 2008 -0800
     1.2 +++ b/src/share/vm/runtime/vm_version.cpp	Fri Feb 22 17:17:14 2008 -0800
     1.3 @@ -52,6 +52,8 @@
     1.4  int Abstract_VM_Version::_vm_minor_version = 0;
     1.5  int Abstract_VM_Version::_vm_build_number = 0;
     1.6  bool Abstract_VM_Version::_initialized = false;
     1.7 +int Abstract_VM_Version::_parallel_worker_threads = 0;
     1.8 +bool Abstract_VM_Version::_parallel_worker_threads_initialized = false;
     1.9  
    1.10  void Abstract_VM_Version::initialize() {
    1.11    if (_initialized) {
    1.12 @@ -210,3 +212,43 @@
    1.13    }
    1.14  #endif
    1.15  }
    1.16 +
    1.17 +unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
    1.18 +                                                      unsigned int num,
    1.19 +                                                      unsigned int den,
    1.20 +                                                      unsigned int switch_pt) {
    1.21 +  if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
    1.22 +    assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
    1.23 +    // For very large machines, there are diminishing returns
    1.24 +    // for large numbers of worker threads.  Instead of
    1.25 +    // hogging the whole system, use a fraction of the workers for every
    1.26 +    // processor after the first 8.  For example, on a 72 cpu machine
    1.27 +    // and a chosen fraction of 5/8
    1.28 +    // use 8 + (72 - 8) * (5/8) == 48 worker threads.
    1.29 +    unsigned int ncpus = (unsigned int) os::active_processor_count();
    1.30 +    return (ncpus <= switch_pt) ?
    1.31 +           ncpus :
    1.32 +          (switch_pt + ((ncpus - switch_pt) * num) / den);
    1.33 +  } else {
    1.34 +    return ParallelGCThreads;
    1.35 +  }
    1.36 +}
    1.37 +
    1.38 +unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
    1.39 +  return nof_parallel_worker_threads(5, 8, 8);
    1.40 +}
    1.41 +
    1.42 +
    1.43 +// Does not set the _initialized flag since it is
    1.44 +// a global flag.
    1.45 +unsigned int Abstract_VM_Version::parallel_worker_threads() {
    1.46 +  if (!_parallel_worker_threads_initialized) {
    1.47 +    if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
    1.48 +      _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
    1.49 +    } else {
    1.50 +      _parallel_worker_threads = ParallelGCThreads;
    1.51 +    }
    1.52 +    _parallel_worker_threads_initialized = true;
    1.53 +  }
    1.54 +  return _parallel_worker_threads;
    1.55 +}

mercurial