271 }
272
273
274 void VM_Version_init() {
275 VM_Version::initialize();
276
277 #ifndef PRODUCT
278 if (PrintMiscellaneous && Verbose) {
279 char buf[512];
280 os::print_cpu_info(tty, buf, sizeof(buf));
281 }
282 #endif
283 }
284
285 unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
286 unsigned int num,
287 unsigned int den,
288 unsigned int switch_pt) {
289 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
290 assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
291 // For very large machines, there are diminishing returns
292 // for large numbers of worker threads. Instead of
293 // hogging the whole system, use a fraction of the workers for every
294 // processor after the first 8. For example, on a 72 cpu machine
295 // and a chosen fraction of 5/8
296 // use 8 + (72 - 8) * (5/8) == 48 worker threads.
297 unsigned int ncpus = (unsigned int) os::active_processor_count();
298 return (ncpus <= switch_pt) ?
299 ncpus :
300 (switch_pt + ((ncpus - switch_pt) * num) / den);
301 } else {
302 return ParallelGCThreads;
303 }
304 }
305
306 unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
307 return nof_parallel_worker_threads(5, 8, 8);
308 }
309
310
311 // Does not set the _initialized flag since it is
312 // a global flag.
313 unsigned int Abstract_VM_Version::parallel_worker_threads() {
314 if (!_parallel_worker_threads_initialized) {
315 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
316 _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
317 } else {
318 _parallel_worker_threads = ParallelGCThreads;
319 }
320 _parallel_worker_threads_initialized = true;
|
271 }
272
273
274 void VM_Version_init() {
275 VM_Version::initialize();
276
277 #ifndef PRODUCT
278 if (PrintMiscellaneous && Verbose) {
279 char buf[512];
280 os::print_cpu_info(tty, buf, sizeof(buf));
281 }
282 #endif
283 }
284
285 unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
286 unsigned int num,
287 unsigned int den,
288 unsigned int switch_pt) {
289 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
290 assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
291 unsigned int threads;
292 // For very large machines, there are diminishing returns
293 // for large numbers of worker threads. Instead of
294 // hogging the whole system, use a fraction of the workers for every
295 // processor after the first 8. For example, on a 72 cpu machine
296 // and a chosen fraction of 5/8
297 // use 8 + (72 - 8) * (5/8) == 48 worker threads.
298 unsigned int ncpus = (unsigned int) os::active_processor_count();
299 threads = (ncpus <= switch_pt) ?
300 ncpus :
301 (switch_pt + ((ncpus - switch_pt) * num) / den);
302 #ifndef _LP64
303 // On 32-bit binaries the virtual address space available to the JVM
304 // is usually limited to 2-3 GB (depends on the platform).
305 // Do not use up address space with too many threads (stacks and per-thread
306 // data). Note that x86 apps running on Win64 have 2 stacks per thread.
307 // GC may more generally scale down threads by max heap size (etc), but the
308 // consequences of over-provisioning threads are higher on 32-bit JVMS,
309 // so add hard limit here:
310 threads = MIN2(threads, (unsigned int)(2*switch_pt));
311 #endif
312 return threads;
313 } else {
314 return ParallelGCThreads;
315 }
316 }
317
318 unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
319 return nof_parallel_worker_threads(5, 8, 8);
320 }
321
322
323 // Does not set the _initialized flag since it is
324 // a global flag.
325 unsigned int Abstract_VM_Version::parallel_worker_threads() {
326 if (!_parallel_worker_threads_initialized) {
327 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
328 _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
329 } else {
330 _parallel_worker_threads = ParallelGCThreads;
331 }
332 _parallel_worker_threads_initialized = true;
|