< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/gcArguments.hpp"
  27 #include "gc/shared/workerPolicy.hpp"
  28 #include "gc/shenandoah/shenandoahArguments.hpp"
  29 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeapRegion.hpp"

  32 #include "utilities/defaultStream.hpp"
  33 
  34 void ShenandoahArguments::initialize() {
  35 #if !(defined AARCH64 || defined AMD64 || defined IA32)
  36   vm_exit_during_initialization("Shenandoah GC is not supported on this platform.");
  37 #endif
  38 
  39 #ifdef IA32
  40   log_warning(gc)("Shenandoah GC is not fully supported on this platform:");
  41   log_warning(gc)("  concurrent modes are not supported, only STW cycles are enabled;");
  42   log_warning(gc)("  arch-specific barrier code is not implemented, disabling barriers;");
  43 
  44   FLAG_SET_DEFAULT(ShenandoahGCHeuristics,           "passive");
  45 
  46   FLAG_SET_DEFAULT(ShenandoahSATBBarrier,            false);
  47   FLAG_SET_DEFAULT(ShenandoahLoadRefBarrier,         false);
  48   FLAG_SET_DEFAULT(ShenandoahKeepAliveBarrier,       false);
  49   FLAG_SET_DEFAULT(ShenandoahStoreValEnqueueBarrier, false);
  50   FLAG_SET_DEFAULT(ShenandoahCASBarrier,             false);
  51   FLAG_SET_DEFAULT(ShenandoahCloneBarrier,           false);

  52 
  53   FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers,     false);








  54 #endif
  55 
  56   if (UseLargePages && (MaxHeapSize / os::large_page_size()) < ShenandoahHeapRegion::MIN_NUM_REGIONS) {
  57     warning("Large pages size (" SIZE_FORMAT "K) is too large to afford page-sized regions, disabling uncommit",
  58             os::large_page_size() / K);
  59     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
  60   }
  61 
  62   // Enable NUMA by default. While Shenandoah is not NUMA-aware, enabling NUMA makes
  63   // storage allocation code NUMA-aware, and NUMA interleaving makes the storage
  64   // allocated in consistent manner (interleaving) to minimize run-to-run variance.
  65   if (FLAG_IS_DEFAULT(UseNUMA)) {
  66     FLAG_SET_DEFAULT(UseNUMA, true);
  67     FLAG_SET_DEFAULT(UseNUMAInterleaving, true);
  68   }
  69 
  70   FLAG_SET_DEFAULT(ParallelGCThreads,
  71                    WorkerPolicy::parallel_worker_threads());
  72 
  73   if (FLAG_IS_DEFAULT(ConcGCThreads)) {


  80   }
  81 
  82   if (ShenandoahRegionSampling && FLAG_IS_DEFAULT(PerfDataMemorySize)) {
  83     // When sampling is enabled, max out the PerfData memory to get more
  84     // Shenandoah data in, including Matrix.
  85     FLAG_SET_DEFAULT(PerfDataMemorySize, 2048*K);
  86   }
  87 
  88 #ifdef COMPILER2
  89   // Shenandoah cares more about pause times, rather than raw throughput.
  90   if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
  91     FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
  92     if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
  93       FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
  94     }
  95   }
  96 #ifdef ASSERT
  97   // C2 barrier verification is only reliable when all default barriers are enabled
  98   if (ShenandoahVerifyOptoBarriers &&
  99           (!FLAG_IS_DEFAULT(ShenandoahSATBBarrier)            ||
 100            !FLAG_IS_DEFAULT(ShenandoahLoadRefBarrier)         ||
 101            !FLAG_IS_DEFAULT(ShenandoahKeepAliveBarrier)       ||
 102            !FLAG_IS_DEFAULT(ShenandoahStoreValEnqueueBarrier) ||
 103            !FLAG_IS_DEFAULT(ShenandoahCASBarrier)             ||
 104            !FLAG_IS_DEFAULT(ShenandoahCloneBarrier)
 105           )) {
 106     warning("Unusual barrier configuration, disabling C2 barrier verification");
 107     FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
 108   }
 109 #else
 110   guarantee(!ShenandoahVerifyOptoBarriers, "Should be disabled");
 111 #endif // ASSERT
 112 #endif // COMPILER2
 113 
 114   if (AlwaysPreTouch) {
 115     // Shenandoah handles pre-touch on its own. It does not let the
 116     // generic storage code to do the pre-touch before Shenandoah has
 117     // a chance to do it on its own.
 118     FLAG_SET_DEFAULT(AlwaysPreTouch, false);
 119     FLAG_SET_DEFAULT(ShenandoahAlwaysPreTouch, true);
 120   }
 121 
 122   // Record more information about previous cycles for improved debugging pleasure
 123   if (FLAG_IS_DEFAULT(LogEventsBufferEntries)) {
 124     FLAG_SET_DEFAULT(LogEventsBufferEntries, 250);
 125   }
 126 
 127   if (ShenandoahAlwaysPreTouch) {
 128     if (!FLAG_IS_DEFAULT(ShenandoahUncommit)) {
 129       warning("AlwaysPreTouch is enabled, disabling ShenandoahUncommit");
 130     }
 131     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
 132   }
 133 
 134   if ((InitialHeapSize == MaxHeapSize) && ShenandoahUncommit) {
 135     log_info(gc)("Min heap equals to max heap, disabling ShenandoahUncommit");
 136     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
 137   }
 138 
 139   // If class unloading is disabled, no unloading for concurrent cycles as well.
 140   // If class unloading is enabled, users should opt-in for unloading during
 141   // concurrent cycles.
 142   if (!ClassUnloading || !FLAG_IS_CMDLINE(ClassUnloadingWithConcurrentMark)) {
 143     log_info(gc)("Consider -XX:+ClassUnloadingWithConcurrentMark if large pause times "
 144                  "are observed on class-unloading sensitive workloads");
 145     FLAG_SET_DEFAULT(ClassUnloadingWithConcurrentMark, false);
 146   }
 147 
 148   // AOT is not supported yet
 149   if (UseAOT) {
 150     if (!FLAG_IS_DEFAULT(UseAOT)) {
 151       warning("Shenandoah does not support AOT at this moment, disabling UseAOT");
 152     }
 153     FLAG_SET_DEFAULT(UseAOT, false);
 154   }
 155 
 156   // TLAB sizing policy makes resizing decisions before each GC cycle. It averages
 157   // historical data, assigning more recent data the weight according to TLABAllocationWeight.
 158   // Current default is good for generational collectors that run frequent young GCs.


 173 
 174   // Make sure safepoint deadlocks are failing predictably. This sets up VM to report
 175   // fatal error after 10 seconds of wait for safepoint syncronization (not the VM
 176   // operation itself). There is no good reason why Shenandoah would spend that
 177   // much time synchronizing.
 178 #ifdef ASSERT
 179   FLAG_SET_DEFAULT(SafepointTimeout, true);
 180   FLAG_SET_DEFAULT(SafepointTimeoutDelay, 10000);
 181   FLAG_SET_DEFAULT(AbortVMOnSafepointTimeout, true);
 182 #endif
 183 }
 184 
 185 size_t ShenandoahArguments::conservative_max_heap_alignment() {
 186   size_t align = ShenandoahMaxRegionSize;
 187   if (UseLargePages) {
 188     align = MAX2(align, os::large_page_size());
 189   }
 190   return align;
 191 }
 192 
 193 void ShenandoahArguments::initialize_alignments() {
 194   // Need to setup sizes early to get correct alignments.
 195   ShenandoahHeapRegion::setup_sizes(MaxHeapSize);
 196 
 197   // This is expected by our algorithm for ShenandoahHeap::heap_region_containing().
 198   size_t align = ShenandoahHeapRegion::region_size_bytes();
 199   if (UseLargePages) {
 200     align = MAX2(align, os::large_page_size());
 201   }
 202   SpaceAlignment = align;
 203   HeapAlignment = align;
 204 }
 205 
 206 CollectedHeap* ShenandoahArguments::create_heap() {
 207   return new ShenandoahHeap(new ShenandoahCollectorPolicy());
 208 }


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/gcArguments.inline.hpp"
  27 #include "gc/shared/workerPolicy.hpp"
  28 #include "gc/shenandoah/shenandoahArguments.hpp"
  29 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  32 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
  33 #include "utilities/defaultStream.hpp"
  34 
  35 void ShenandoahArguments::initialize() {
  36 #if !(defined AARCH64 || defined AMD64 || defined IA32)
  37   vm_exit_during_initialization("Shenandoah GC is not supported on this platform.");
  38 #endif
  39 
  40 #ifdef IA32
  41   log_warning(gc)("Shenandoah GC is not fully supported on this platform:");
  42   log_warning(gc)("  concurrent modes are not supported, only STW cycles are enabled;");
  43   log_warning(gc)("  arch-specific barrier code is not implemented, disabling barriers;");
  44 
  45   FLAG_SET_DEFAULT(ShenandoahGCHeuristics,           "passive");
  46 
  47   FLAG_SET_DEFAULT(ShenandoahSATBBarrier,            false);

  48   FLAG_SET_DEFAULT(ShenandoahKeepAliveBarrier,       false);
  49   FLAG_SET_DEFAULT(ShenandoahStoreValEnqueueBarrier, false);
  50   FLAG_SET_DEFAULT(ShenandoahCASBarrier,             false);
  51   FLAG_SET_DEFAULT(ShenandoahCloneBarrier,           false);
  52 #endif
  53 
  54 #ifdef _LP64
  55   // The optimized ObjArrayChunkedTask takes some bits away from the full 64 addressable
  56   // bits, fail if we ever attempt to address more than we can. Only valid on 64bit.
  57   if (MaxHeapSize >= ObjArrayChunkedTask::max_addressable()) {
  58     jio_fprintf(defaultStream::error_stream(),
  59                 "Shenandoah GC cannot address more than " SIZE_FORMAT " bytes, and " SIZE_FORMAT " bytes heap requested.",
  60                 ObjArrayChunkedTask::max_addressable(), MaxHeapSize);
  61     vm_exit(1);
  62   }
  63 #endif
  64 
  65   if (UseLargePages && (MaxHeapSize / os::large_page_size()) < ShenandoahHeapRegion::MIN_NUM_REGIONS) {
  66     warning("Large pages size (" SIZE_FORMAT "K) is too large to afford page-sized regions, disabling uncommit",
  67             os::large_page_size() / K);
  68     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
  69   }
  70 
  71   // Enable NUMA by default. While Shenandoah is not NUMA-aware, enabling NUMA makes
  72   // storage allocation code NUMA-aware, and NUMA interleaving makes the storage
  73   // allocated in consistent manner (interleaving) to minimize run-to-run variance.
  74   if (FLAG_IS_DEFAULT(UseNUMA)) {
  75     FLAG_SET_DEFAULT(UseNUMA, true);
  76     FLAG_SET_DEFAULT(UseNUMAInterleaving, true);
  77   }
  78 
  79   FLAG_SET_DEFAULT(ParallelGCThreads,
  80                    WorkerPolicy::parallel_worker_threads());
  81 
  82   if (FLAG_IS_DEFAULT(ConcGCThreads)) {


  89   }
  90 
  91   if (ShenandoahRegionSampling && FLAG_IS_DEFAULT(PerfDataMemorySize)) {
  92     // When sampling is enabled, max out the PerfData memory to get more
  93     // Shenandoah data in, including Matrix.
  94     FLAG_SET_DEFAULT(PerfDataMemorySize, 2048*K);
  95   }
  96 
  97 #ifdef COMPILER2
  98   // Shenandoah cares more about pause times, rather than raw throughput.
  99   if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
 100     FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
 101     if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
 102       FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
 103     }
 104   }
 105 #ifdef ASSERT
 106   // C2 barrier verification is only reliable when all default barriers are enabled
 107   if (ShenandoahVerifyOptoBarriers &&
 108           (!FLAG_IS_DEFAULT(ShenandoahSATBBarrier)            ||

 109            !FLAG_IS_DEFAULT(ShenandoahKeepAliveBarrier)       ||
 110            !FLAG_IS_DEFAULT(ShenandoahStoreValEnqueueBarrier) ||
 111            !FLAG_IS_DEFAULT(ShenandoahCASBarrier)             ||
 112            !FLAG_IS_DEFAULT(ShenandoahCloneBarrier)
 113           )) {
 114     warning("Unusual barrier configuration, disabling C2 barrier verification");
 115     FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
 116   }
 117 #else
 118   guarantee(!ShenandoahVerifyOptoBarriers, "Should be disabled");
 119 #endif // ASSERT
 120 #endif // COMPILER2
 121 
 122   if (AlwaysPreTouch) {
 123     // Shenandoah handles pre-touch on its own. It does not let the
 124     // generic storage code to do the pre-touch before Shenandoah has
 125     // a chance to do it on its own.
 126     FLAG_SET_DEFAULT(AlwaysPreTouch, false);
 127     FLAG_SET_DEFAULT(ShenandoahAlwaysPreTouch, true);
 128   }
 129 
 130   // Record more information about previous cycles for improved debugging pleasure
 131   if (FLAG_IS_DEFAULT(LogEventsBufferEntries)) {
 132     FLAG_SET_DEFAULT(LogEventsBufferEntries, 250);
 133   }
 134 
 135   if (ShenandoahAlwaysPreTouch) {
 136     if (!FLAG_IS_DEFAULT(ShenandoahUncommit)) {
 137       warning("AlwaysPreTouch is enabled, disabling ShenandoahUncommit");
 138     }
 139     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
 140   }
 141 





 142   // If class unloading is disabled, no unloading for concurrent cycles as well.
 143   // If class unloading is enabled, users should opt-in for unloading during
 144   // concurrent cycles.
 145   if (!ClassUnloading || !FLAG_IS_CMDLINE(ClassUnloadingWithConcurrentMark)) {
 146     log_info(gc)("Consider -XX:+ClassUnloadingWithConcurrentMark if large pause times "
 147                  "are observed on class-unloading sensitive workloads");
 148     FLAG_SET_DEFAULT(ClassUnloadingWithConcurrentMark, false);
 149   }
 150 
 151   // AOT is not supported yet
 152   if (UseAOT) {
 153     if (!FLAG_IS_DEFAULT(UseAOT)) {
 154       warning("Shenandoah does not support AOT at this moment, disabling UseAOT");
 155     }
 156     FLAG_SET_DEFAULT(UseAOT, false);
 157   }
 158 
 159   // TLAB sizing policy makes resizing decisions before each GC cycle. It averages
 160   // historical data, assigning more recent data the weight according to TLABAllocationWeight.
 161   // Current default is good for generational collectors that run frequent young GCs.


 176 
 177   // Make sure safepoint deadlocks are failing predictably. This sets up VM to report
 178   // fatal error after 10 seconds of wait for safepoint syncronization (not the VM
 179   // operation itself). There is no good reason why Shenandoah would spend that
 180   // much time synchronizing.
 181 #ifdef ASSERT
 182   FLAG_SET_DEFAULT(SafepointTimeout, true);
 183   FLAG_SET_DEFAULT(SafepointTimeoutDelay, 10000);
 184   FLAG_SET_DEFAULT(AbortVMOnSafepointTimeout, true);
 185 #endif
 186 }
 187 
 188 size_t ShenandoahArguments::conservative_max_heap_alignment() {
 189   size_t align = ShenandoahMaxRegionSize;
 190   if (UseLargePages) {
 191     align = MAX2(align, os::large_page_size());
 192   }
 193   return align;
 194 }
 195 













 196 CollectedHeap* ShenandoahArguments::create_heap() {
 197   return create_heap_with_policy<ShenandoahHeap, ShenandoahCollectorPolicy>();
 198 }
< prev index next >