From a2d0e639b033b135db68ac101b697a63643fa919 Mon Sep 17 00:00:00 2001 From: brutisso Date: Sun, 30 Dec 2012 08:47:52 +0100 Subject: [PATCH] 8005396: Use ParNew with only one thread instead of DefNew as default for CMS on single CPU machines Reviewed-by: jmasa, jcoomes --- .../cmsCollectorPolicy.cpp | 6 +- .../parNew/parNewGeneration.cpp | 4 -- .../parNew/parNewGeneration.hpp | 2 - src/share/vm/memory/collectorPolicy.cpp | 7 +- src/share/vm/memory/tenuredGeneration.cpp | 2 +- src/share/vm/runtime/arguments.cpp | 69 +++++++++---------- 6 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp index 5123d460c..e57d405e5 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @@ -56,7 +56,7 @@ void ConcurrentMarkSweepPolicy::initialize_generations() { if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); - if (ParNewGeneration::in_use()) { + if (UseParNewGC) { if (UseAdaptiveSizePolicy) { _generations[0] = new GenerationSpec(Generation::ASParNew, _initial_gen0_size, _max_gen0_size); @@ -96,7 +96,7 @@ void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size, void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { // initialize the policy counters - 2 collectors, 3 generations - if (ParNewGeneration::in_use()) { + if (UseParNewGC) { _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3); } else { @@ -119,7 +119,7 @@ void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() { assert(size_policy() != NULL, "A size policy is required"); // initialize the policy counters - 2 collectors, 3 generations - if (ParNewGeneration::in_use()) { + if (UseParNewGC) { _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3, size_policy()); } diff --git a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index ea432002a..273322436 100644 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -1623,7 +1623,3 @@ void ParNewGeneration::ref_processor_init() const char* ParNewGeneration::name() const { return "par new generation"; } - -bool ParNewGeneration::in_use() { - return UseParNewGC && ParallelGCThreads > 0; -} diff --git a/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp b/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp index b8a2d1ea0..bbb6176fd 100644 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp @@ -361,8 +361,6 @@ class ParNewGeneration: public DefNewGeneration { delete _task_queues; } - static bool in_use(); - virtual void ref_processor_init(); virtual Generation::Name kind() { return Generation::ParNew; } virtual const char* name() const; diff --git a/src/share/vm/memory/collectorPolicy.cpp b/src/share/vm/memory/collectorPolicy.cpp index 6857181a5..b13d97611 100644 --- a/src/share/vm/memory/collectorPolicy.cpp +++ b/src/share/vm/memory/collectorPolicy.cpp @@ -827,7 +827,7 @@ void MarkSweepPolicy::initialize_generations() { if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); - if (UseParNewGC && ParallelGCThreads > 0) { + if (UseParNewGC) { _generations[0] = new GenerationSpec(Generation::ParNew, _initial_gen0_size, _max_gen0_size); } else { _generations[0] = new GenerationSpec(Generation::DefNew, _initial_gen0_size, _max_gen0_size); @@ -840,10 +840,9 @@ void MarkSweepPolicy::initialize_generations() { void MarkSweepPolicy::initialize_gc_policy_counters() { // initialize the policy counters - 2 collectors, 3 generations - if (UseParNewGC && ParallelGCThreads > 0) { + if (UseParNewGC) { _gc_policy_counters = new GCPolicyCounters("ParNew:MSC", 2, 3); - } - else { + } else { _gc_policy_counters = new GCPolicyCounters("Copy:MSC", 2, 3); } } diff --git a/src/share/vm/memory/tenuredGeneration.cpp b/src/share/vm/memory/tenuredGeneration.cpp index 1d38095f8..f47ea307d 100644 --- a/src/share/vm/memory/tenuredGeneration.cpp +++ b/src/share/vm/memory/tenuredGeneration.cpp @@ -62,7 +62,7 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs, _virtual_space.reserved_size(), _the_space, _gen_counters); #ifndef SERIALGC - if (UseParNewGC && ParallelGCThreads > 0) { + if (UseParNewGC) { typedef ParGCAllocBufferWithBOT* ParGCAllocBufferWithBOTPtr; _alloc_buffers = NEW_C_HEAP_ARRAY(ParGCAllocBufferWithBOTPtr, ParallelGCThreads, mtGC); diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp index 21e5cce7b..4d1b9366d 100644 --- a/src/share/vm/runtime/arguments.cpp +++ b/src/share/vm/runtime/arguments.cpp @@ -1083,10 +1083,6 @@ static void disable_adaptive_size_policy(const char* collector_name) { } } -// If the user has chosen ParallelGCThreads > 0, we set UseParNewGC -// if it's not explictly set or unset. If the user has chosen -// UseParNewGC and not explicitly set ParallelGCThreads we -// set it, unless this is a single cpu machine. void Arguments::set_parnew_gc_flags() { assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC, "control point invariant"); @@ -1095,42 +1091,41 @@ void Arguments::set_parnew_gc_flags() { // Turn off AdaptiveSizePolicy for parnew until it is complete. disable_adaptive_size_policy("UseParNewGC"); - if (ParallelGCThreads == 0) { - FLAG_SET_DEFAULT(ParallelGCThreads, - Abstract_VM_Version::parallel_worker_threads()); - if (ParallelGCThreads == 1) { - FLAG_SET_DEFAULT(UseParNewGC, false); - FLAG_SET_DEFAULT(ParallelGCThreads, 0); - } + if (FLAG_IS_DEFAULT(ParallelGCThreads)) { + FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads()); + assert(ParallelGCThreads > 0, "We should always have at least one thread by default"); + } else if (ParallelGCThreads == 0) { + jio_fprintf(defaultStream::error_stream(), + "The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n"); + vm_exit(1); } - if (UseParNewGC) { - // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively, - // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration - // we set them to 1024 and 1024. - // See CR 6362902. - if (FLAG_IS_DEFAULT(YoungPLABSize)) { - FLAG_SET_DEFAULT(YoungPLABSize, (intx)1024); - } - if (FLAG_IS_DEFAULT(OldPLABSize)) { - FLAG_SET_DEFAULT(OldPLABSize, (intx)1024); - } - - // AlwaysTenure flag should make ParNew promote all at first collection. - // See CR 6362902. - if (AlwaysTenure) { - FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0); - } - // When using compressed oops, we use local overflow stacks, - // rather than using a global overflow list chained through - // the klass word of the object's pre-image. - if (UseCompressedOops && !ParGCUseLocalOverflow) { - if (!FLAG_IS_DEFAULT(ParGCUseLocalOverflow)) { - warning("Forcing +ParGCUseLocalOverflow: needed if using compressed references"); - } - FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true); + + // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively, + // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration + // we set them to 1024 and 1024. + // See CR 6362902. + if (FLAG_IS_DEFAULT(YoungPLABSize)) { + FLAG_SET_DEFAULT(YoungPLABSize, (intx)1024); + } + if (FLAG_IS_DEFAULT(OldPLABSize)) { + FLAG_SET_DEFAULT(OldPLABSize, (intx)1024); + } + + // AlwaysTenure flag should make ParNew promote all at first collection. + // See CR 6362902. + if (AlwaysTenure) { + FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0); + } + // When using compressed oops, we use local overflow stacks, + // rather than using a global overflow list chained through + // the klass word of the object's pre-image. + if (UseCompressedOops && !ParGCUseLocalOverflow) { + if (!FLAG_IS_DEFAULT(ParGCUseLocalOverflow)) { + warning("Forcing +ParGCUseLocalOverflow: needed if using compressed references"); } - assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error"); + FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true); } + assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error"); } // Adjust some sizes to suit CMS and/or ParNew needs; these work well on -- GitLab