1 /*
   2  * Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP
  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP
  26 
  27 #include "runtime/globals.hpp"
  28 
  29 #define SHENANDOAH_FLAGS(develop, \
  30                          develop_pd, \
  31                          product, \
  32                          product_pd, \
  33                          diagnostic, \
  34                          experimental, \
  35                          notproduct, \
  36                          manageable, \
  37                          product_rw) \
  38                                                                             \
  39   experimental(uintx, ShenandoahRegionSize, 0,                              \
  40           "Static heap region size. Set zero to enable automatic sizing.")  \
  41                                                                             \
  42   experimental(uintx, ShenandoahTargetNumRegions, 2048,                     \
  43           "With automatic region sizing, this is the approximate number "   \
  44           "of regions that would be used, within min/max region size "      \
  45           "limits.")                                                        \
  46                                                                             \
  47   experimental(uintx, ShenandoahMinRegionSize, 256 * K,                     \
  48           "With automatic region sizing, the regions would be at least "    \
  49           "this large.")                                                    \
  50                                                                             \
  51   experimental(uintx, ShenandoahMaxRegionSize, 32 * M,                      \
  52           "With automatic region sizing, the regions would be at most "     \
  53           "this large.")                                                    \
  54                                                                             \
  55   experimental(intx, ShenandoahHumongousThreshold, 100,                     \
  56           "Humongous objects are allocated in separate regions. "           \
  57           "This setting defines how large the object should be to be "      \
  58           "deemed humongous. Value is in  percents of heap region size. "   \
  59           "This also caps the maximum TLAB size.")                          \
  60                                                                             \
  61   product(ccstr, ShenandoahGCMode, "satb",                                  \
  62           "GC mode to use.  Among other things, this defines which "        \
  63           "barriers are in in use. Possible values are:"                    \
  64           " satb - snapshot-at-the-beginning concurrent GC (three pass mark-evac-update);"  \
  65           " iu - incremental-update concurrent GC (three pass mark-evac-update);"  \
  66           " passive - stop the world GC only (either degenerated or full)") \
  67                                                                             \
  68   product(ccstr, ShenandoahGCHeuristics, "adaptive",                        \
  69           "GC heuristics to use. This fine-tunes the GC mode selected, "    \
  70           "by choosing when to start the GC, how much to process on each "  \
  71           "cycle, and what other features to automatically enable. "        \
  72           "Possible values are:"                                            \
  73           " adaptive - adapt to maintain the given amount of free heap "    \
  74           "at all times, even during the GC cycle;"                         \
  75           " static -  trigger GC when free heap falls below the threshold;" \
  76           " aggressive - run GC continuously, try to evacuate everything;"  \
  77           " compact - run GC more frequently and with deeper targets to "   \
  78           "free up more memory.")                                           \
  79                                                                             \
  80   experimental(uintx, ShenandoahRefProcFrequency, 5,                        \
  81           "Process process weak (soft, phantom, finalizers) references "    \
  82           "every Nth cycle. Normally affects concurrent GC cycles only, "   \
  83           "as degenerated and full GCs would try to process references "    \
  84           "regardless. Set to zero to disable reference processing "        \
  85           "completely.")                                                    \
  86                                                                             \
  87   experimental(uintx, ShenandoahUnloadClassesFrequency, 100,                \
  88           "Unload the classes every Nth cycle. Normally affects concurrent "\
  89           "GC cycles, as degenerated and full GCs would try to unload "     \
  90           "classes regardless. Set to zero to disable class unloading.")    \
  91                                                                             \
  92   experimental(uintx, ShenandoahGarbageThreshold, 25,                       \
  93           "How much garbage a region has to contain before it would be "    \
  94           "taken for collection. This a guideline only, as GC heuristics "  \
  95           "may select the region for collection even if it has little "     \
  96           "garbage. This also affects how much internal fragmentation the " \
  97           "collector accepts. In percents of heap region size.")            \
  98                                                                             \
  99   experimental(uintx, ShenandoahInitFreeThreshold, 70,                      \
 100           "How much heap should be free before some heuristics trigger the "\
 101           "initial (learning) cycles. Affects cycle frequency on startup "  \
 102           "and after drastic state changes, e.g. after degenerated/full "   \
 103           "GC cycles. In percents of total heap size.")                     \
 104                                                                             \
 105   experimental(uintx, ShenandoahMinFreeThreshold, 10,                       \
 106           "How much heap should be free before most heuristics trigger the "\
 107           "collection, even without other triggers. Provides the safety "   \
 108           "margin for many heuristics. In percents of total heap size.")    \
 109                                                                             \
 110   experimental(uintx, ShenandoahAllocationThreshold, 0,                     \
 111           "How many new allocations should happen since the last GC cycle " \
 112           "before some heuristics trigger the collection. In percents of "  \
 113           "total heap size. Set to zero to effectively disable.")           \
 114                                                                             \
 115   experimental(uintx, ShenandoahAllocSpikeFactor, 5,                        \
 116           "How much of heap should some heuristics reserve for absorbing "  \
 117           "the allocation spikes. Larger value wastes more memory in "      \
 118           "non-emergency cases, but provides more safety in emergency "     \
 119           "cases. In percents of total heap size.")                         \
 120                                                                             \
 121   experimental(uintx, ShenandoahLearningSteps, 5,                           \
 122           "The number of cycles some heuristics take to collect in order "  \
 123           "to learn application and GC performance.")                       \
 124                                                                             \
 125   experimental(uintx, ShenandoahImmediateThreshold, 90,                     \
 126           "The cycle may shortcut when enough garbage can be reclaimed "    \
 127           "from the immediate garbage (completely garbage regions). "       \
 128           "In percents of total garbage found. Setting this threshold "     \
 129           "to 100 effectively disables the shortcut.")                      \
 130                                                                             \
 131   experimental(uintx, ShenandoahGuaranteedGCInterval, 5*60*1000,            \
 132           "Many heuristics would guarantee a concurrent GC cycle at "       \
 133           "at least with this interval. This is useful when large idle"     \
 134           " intervals are present, where GC can run without stealing "      \
 135           "time from active application. Time is in milliseconds."          \
 136           "Setting this to 0 disables the feature.")                        \
 137                                                                             \
 138   experimental(bool, ShenandoahAlwaysClearSoftRefs, false,                  \
 139           "Unconditionally clear soft references, instead of using any "    \
 140           "other cleanup policy. This minimizes footprint at expense of"    \
 141           "more soft reference churn in applications.")                     \
 142                                                                             \
 143   experimental(bool, ShenandoahUncommit, true,                              \
 144           "Allow to uncommit memory under unused regions and metadata. "    \
 145           "This optimizes footprint at expense of allocation latency in "   \
 146           "regions that require committing back. Uncommits would be "       \
 147           "disabled by some heuristics, or with static heap size.")         \
 148                                                                             \
 149   experimental(uintx, ShenandoahUncommitDelay, 5*60*1000,                   \
 150           "Uncommit memory for regions that were not used for more than "   \
 151           "this time. First use after that would incur allocation stalls. " \
 152           "Actively used regions would never be uncommitted, because they " \
 153           "do not become unused longer than this delay. Time is in "        \
 154           "milliseconds. Setting this delay to 0 effectively uncommits "    \
 155           "regions almost immediately after they become unused.")           \
 156                                                                             \
 157   experimental(bool, ShenandoahRegionSampling, false,                       \
 158           "Provide heap region sampling data via jvmstat.")                 \
 159                                                                             \
 160   experimental(int, ShenandoahRegionSamplingRate, 40,                       \
 161           "Sampling rate for heap region sampling. In milliseconds between "\
 162           "the samples. Higher values provide more fidelity, at expense "   \
 163           "of more sampling overhead.")                                     \
 164                                                                             \
 165   experimental(uintx, ShenandoahControlIntervalMin, 1,                      \
 166           "The minimum sleep interval for the control loop that drives "    \
 167           "the cycles. Lower values would increase GC responsiveness "      \
 168           "to changing heap conditions, at the expense of higher perf "     \
 169           "overhead. Time is in milliseconds.")                             \
 170                                                                             \
 171   experimental(uintx, ShenandoahControlIntervalMax, 10,                     \
 172           "The maximum sleep interval for control loop that drives "        \
 173           "the cycles. Lower values would increase GC responsiveness "      \
 174           "to changing heap conditions, at the expense of higher perf "     \
 175           "overhead. Time is in milliseconds.")                             \
 176                                                                             \
 177   experimental(uintx, ShenandoahControlIntervalAdjustPeriod, 1000,          \
 178           "The time period for one step in control loop interval "          \
 179           "adjustment. Lower values make adjustments faster, at the "       \
 180           "expense of higher perf overhead. Time is in milliseconds.")      \
 181                                                                             \
 182   diagnostic(bool, ShenandoahVerify, false,                                 \
 183           "Enable internal verification. This would catch many GC bugs, "   \
 184           "but it would also stall the collector during the verification, " \
 185           "which prolongs the pauses and might hide other bugs.")           \
 186                                                                             \
 187   diagnostic(intx, ShenandoahVerifyLevel, 4,                                \
 188           "Verification level, higher levels check more, taking more time. "\
 189           "Accepted values are:"                                            \
 190           " 0 = basic heap checks; "                                        \
 191           " 1 = previous level, plus basic region checks; "                 \
 192           " 2 = previous level, plus all roots; "                           \
 193           " 3 = previous level, plus all reachable objects; "               \
 194           " 4 = previous level, plus all marked objects")                   \
 195                                                                             \
 196   diagnostic(bool, ShenandoahElasticTLAB, true,                             \
 197           "Use Elastic TLABs with Shenandoah")                              \
 198                                                                             \
 199   experimental(uintx, ShenandoahEvacReserve, 5,                             \
 200           "How much of heap to reserve for evacuations. Larger values make "\
 201           "GC evacuate more live objects on every cycle, while leaving "    \
 202           "less headroom for application to allocate in. In percents of "   \
 203           "total heap size.")                                               \
 204                                                                             \
 205   experimental(double, ShenandoahEvacWaste, 1.2,                            \
 206           "How much waste evacuations produce within the reserved space. "  \
 207           "Larger values make evacuations more resilient against "          \
 208           "evacuation conflicts, at expense of evacuating less on each "    \
 209           "GC cycle.")                                                      \
 210                                                                             \
 211   experimental(bool, ShenandoahEvacReserveOverflow, true,                   \
 212           "Allow evacuations to overflow the reserved space. Enabling it "  \
 213           "will make evacuations more resilient when evacuation "           \
 214           "reserve/waste is incorrect, at the risk that application "       \
 215           "runs out of memory too early.")                                  \
 216                                                                             \
 217   experimental(bool, ShenandoahPacing, true,                                \
 218           "Pace application allocations to give GC chance to start "        \
 219           "and complete before allocation failure is reached.")             \
 220                                                                             \
 221   experimental(uintx, ShenandoahPacingMaxDelay, 10,                         \
 222           "Max delay for pacing application allocations. Larger values "    \
 223           "provide more resilience against out of memory, at expense at "   \
 224           "hiding the GC latencies in the allocation path. Time is in "     \
 225           "milliseconds. Setting it to arbitrarily large value makes "      \
 226           "GC effectively stall the threads indefinitely instead of going " \
 227           "to degenerated or Full GC.")                                     \
 228                                                                             \
 229   experimental(uintx, ShenandoahPacingIdleSlack, 2,                         \
 230           "How much of heap counted as non-taxable allocations during idle "\
 231           "phases. Larger value makes the pacing milder when collector is " \
 232           "idle, requiring less rendezvous with control thread. Lower "     \
 233           "value makes the pacing control less responsive to out-of-cycle " \
 234           "allocs. In percent of total heap size.")                         \
 235                                                                             \
 236   experimental(uintx, ShenandoahPacingCycleSlack, 10,                       \
 237           "How much of free space to take as non-taxable allocations "      \
 238           "the GC cycle. Larger value makes the pacing milder at the "      \
 239           "beginning of the GC cycle. Lower value makes the pacing less "   \
 240           "uniform during the cycle. In percent of free space.")            \
 241                                                                             \
 242   experimental(double, ShenandoahPacingSurcharge, 1.1,                      \
 243           "Additional pacing tax surcharge to help unclutter the heap. "    \
 244           "Larger values makes the pacing more aggressive. Lower values "   \
 245           "risk GC cycles finish with less memory than were available at "  \
 246           "the beginning of it.")                                           \
 247                                                                             \
 248   experimental(uintx, ShenandoahCriticalFreeThreshold, 1,                   \
 249           "How much of the heap needs to be free after recovery cycles, "   \
 250           "either Degenerated or Full GC to be claimed successful. If this "\
 251           "much space is not available, next recovery step would be "       \
 252           "triggered.")                                                     \
 253                                                                             \
 254   diagnostic(bool, ShenandoahDegeneratedGC, true,                           \
 255           "Enable Degenerated GC as the graceful degradation step. "        \
 256           "Disabling this option leads to degradation to Full GC instead. " \
 257           "When running in passive mode, this can be toggled to measure "   \
 258           "either Degenerated GC or Full GC costs.")                        \
 259                                                                             \
 260   experimental(uintx, ShenandoahFullGCThreshold, 3,                         \
 261           "How many back-to-back Degenerated GCs should happen before "     \
 262           "going to a Full GC.")                                            \
 263                                                                             \
 264   experimental(bool, ShenandoahImplicitGCInvokesConcurrent, false,          \
 265           "Should internally-caused GC requests invoke concurrent cycles, " \
 266           "should they do the stop-the-world (Degenerated / Full GC)? "     \
 267           "Many heuristics automatically enable this. This option is "      \
 268           "similar to global ExplicitGCInvokesConcurrent.")                 \
 269                                                                             \
 270   diagnostic(bool, ShenandoahHumongousMoves, true,                          \
 271           "Allow moving humongous regions. This makes GC more resistant "   \
 272           "to external fragmentation that may otherwise fail other "        \
 273           "humongous allocations, at the expense of higher GC copying "     \
 274           "costs. Currently affects stop-the-world (Full) cycle only.")     \
 275                                                                             \
 276   diagnostic(bool, ShenandoahOOMDuringEvacALot, false,                      \
 277           "Testing: simulate OOM during evacuation.")                       \
 278                                                                             \
 279   diagnostic(bool, ShenandoahAllocFailureALot, false,                       \
 280           "Testing: make lots of artificial allocation failures.")          \
 281                                                                             \
 282   experimental(intx, ShenandoahMarkScanPrefetch, 32,                        \
 283           "How many objects to prefetch ahead when traversing mark bitmaps."\
 284           "Set to 0 to disable prefetching.")                               \
 285                                                                             \
 286   experimental(uintx, ShenandoahMarkLoopStride, 1000,                       \
 287           "How many items to process during one marking iteration before "  \
 288           "checking for cancellation, yielding, etc. Larger values improve "\
 289           "marking performance at expense of responsiveness.")              \
 290                                                                             \
 291   experimental(uintx, ShenandoahParallelRegionStride, 1024,                 \
 292           "How many regions to process at once during parallel region "     \
 293           "iteration. Affects heaps with lots of regions.")                 \
 294                                                                             \
 295   experimental(intx, ShenandoahSATBBufferSize, 1 * K,                       \
 296           "Number of entries in an SATB log buffer.")                       \
 297                                                                             \
 298   experimental(uintx, ShenandoahSATBBufferFlushInterval, 100,               \
 299           "Forcefully flush non-empty SATB buffers at this interval. "      \
 300           "Time is in milliseconds.")                                       \
 301                                                                             \
 302   diagnostic(bool, ShenandoahPreclean, true,                                \
 303           "Do concurrent preclean phase before final mark: process "        \
 304           "definitely alive references to avoid dealing with them during "  \
 305           "pause.")                                                         \
 306                                                                             \
 307   diagnostic(bool, ShenandoahSATBBarrier, true,                             \
 308           "Turn on/off SATB barriers in Shenandoah")                        \
 309                                                                             \
 310   diagnostic(bool, ShenandoahStoreValEnqueueBarrier, false,                 \
 311           "Turn on/off enqueuing of oops for storeval barriers")            \
 312                                                                             \
 313   diagnostic(bool, ShenandoahCASBarrier, true,                              \
 314           "Turn on/off CAS barriers in Shenandoah")                         \
 315                                                                             \
 316   diagnostic(bool, ShenandoahCloneBarrier, true,                            \
 317           "Turn on/off clone barriers in Shenandoah")                       \
 318                                                                             \
 319   diagnostic(bool, ShenandoahLoadRefBarrier, true,                          \
 320           "Turn on/off load-reference barriers in Shenandoah")              \
 321                                                                             \
 322   diagnostic(uintx, ShenandoahCodeRootsStyle, 2,                            \
 323           "Use this style to scan the code cache roots:"                    \
 324           " 0 - sequential iterator;"                                       \
 325           " 1 - parallel iterator;"                                         \
 326           " 2 - parallel iterator with cset filters;")                      \
 327                                                                             \
 328   diagnostic(bool, ShenandoahOptimizeStaticFinals, true,                    \
 329           "Optimize barriers on static final fields. "                      \
 330           "Turn it off for maximum compatibility with reflection or JNI "   \
 331           "code that manipulates final fields.")                            \
 332                                                                             \
 333   develop(bool, ShenandoahVerifyOptoBarriers, false,                        \
 334           "Verify no missing barriers in C2.")                              \
 335                                                                             \
 336   product(bool, ShenandoahLogTrace, false,                                  \
 337           "Turns on logging in Shenandoah at trace level. ")                \
 338                                                                             \
 339   product(bool, ShenandoahLogDebug, false,                                  \
 340           "Turns on logging in Shenandoah at debug level. ")                \
 341                                                                             \
 342   product(bool, ShenandoahLogInfo, false,                                   \
 343           "Turns on logging in Shenandoah at info level. ")                 \
 344                                                                             \
 345   product(bool, ShenandoahLogWarning, false,                                \
 346           "Turns on logging in Shenandoah at warning level. ")              \
 347                                                                             \
 348 
 349 SHENANDOAH_FLAGS(DECLARE_DEVELOPER_FLAG, \
 350                  DECLARE_PD_DEVELOPER_FLAG,     \
 351                  DECLARE_PRODUCT_FLAG,          \
 352                  DECLARE_PD_PRODUCT_FLAG,       \
 353                  DECLARE_DIAGNOSTIC_FLAG,       \
 354                  DECLARE_EXPERIMENTAL_FLAG,     \
 355                  DECLARE_NOTPRODUCT_FLAG,       \
 356                  DECLARE_MANAGEABLE_FLAG,       \
 357                  DECLARE_PRODUCT_RW_FLAG)
 358 
 359 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP