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