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, ShenandoahHeapRegionSize, 0,                         \
  44           "Size of the Shenandoah regions. Set to zero to detect "          \
  45           "automatically.")                                                 \
  46                                                                             \
  47   experimental(size_t, ShenandoahTargetNumRegions, 2048,                    \
  48           "Target number of regions. We try to get around that many "       \
  49           "regions, based on Shenandoah{Min,Max}RegionSize.")               \
  50                                                                             \
  51   experimental(size_t, ShenandoahMinRegionSize, 256 * K,                    \
  52           "Minimum Shenandoah heap region size.")                           \
  53                                                                             \
  54   experimental(size_t, ShenandoahMaxRegionSize, 32 * M,                     \
  55           "Maximum Shenandoah heap region size.")                           \
  56                                                                             \
  57   experimental(intx, ShenandoahHumongousThreshold, 100,                     \
  58           "How large should the object be to get allocated in humongous "   \
  59           "region, in percents of heap region size. This also caps the "    \
  60           "maximum TLAB size.")                                             \
  61           range(1, 100)                                                     \
  62                                                                             \
  63   experimental(ccstr, ShenandoahGCHeuristics, "adaptive",                   \
  64           "The heuristics to use in Shenandoah GC. Possible values:"        \
  65           " *) adaptive - adapt to maintain the given amount of free heap;" \
  66           " *) static  -  start concurrent GC when static free heap "       \
  67           "               threshold and static allocation threshold are "   \
  68           "               tripped;"                                         \
  69           " *) aggressive - run concurrent GC continuously, evacuate "      \
  70           "               everything;"                                      \
  71           " *) compact - run GC with lower footprint target, may end up "   \
  72           "               doing continuous GC, evacuate lots of live "      \
  73           "               objects, uncommit heap aggressively;")            \
  74                                                                             \
  75   experimental(ccstr, ShenandoahGCMode, "normal",                           \
  76           "The GC mode to use in Shenandoah GC. Possible values"            \
  77           " *) normal    - normal GC (mark-evac-update)"                    \
  78           " *) traversal - traversal GC (single-pass)"                      \
  79           " *) passive   - disable concurrent GC, do stop-the-world GC")    \
  80                                                                             \
  81   experimental(ccstr, ShenandoahUpdateRefsEarly, "adaptive",                \
  82           "Run a separate concurrent reference updating phase after"        \
  83           "concurrent evacuation. Possible values: 'on', 'off', 'adaptive'")\
  84                                                                             \
  85   experimental(uintx, ShenandoahRefProcFrequency, 5,                        \
  86           "How often should (weak, soft, etc) references be processed. "    \
  87           "References get processed at every Nth GC cycle. Set to zero "    \
  88           "to disable reference processing.")                               \
  89                                                                             \
  90   experimental(uintx, ShenandoahUnloadClassesFrequency, 1,                  \
  91           "How often should classes get unloaded. "                         \
  92           "Class unloading is performed at every Nth GC cycle. "            \
  93           "Set to zero to disable class unloading during concurrent GC.")   \
  94                                                                             \
  95   experimental(uintx, ShenandoahGarbageThreshold, 60,                       \
  96           "Sets the percentage of garbage a region need to contain before " \
  97           "it can be marked for collection. Does not apply to all "         \
  98           "heuristics.")                                                    \
  99           range(0,100)                                                      \
 100                                                                             \
 101   experimental(uintx, ShenandoahInitFreeThreshold, 70,                      \
 102           "Initial remaining free heap threshold for learning steps in "    \
 103           "heuristics. In percents of total heap size. Does not apply to "  \
 104           "all heuristics.")                                                \
 105           range(0,100)                                                      \
 106                                                                             \
 107   experimental(uintx, ShenandoahMinFreeThreshold, 10,                       \
 108           "Minimum remaining free space threshold, after which collection " \
 109           "definitely triggers. Does not apply to all heuristics.")         \
 110           range(0,100)                                                      \
 111                                                                             \
 112   experimental(uintx, ShenandoahAllocationThreshold, 0,                     \
 113           "Set percentage of memory allocated since last GC cycle before "  \
 114           "a new GC cycle can be started. Set to zero to effectively "      \
 115           "disable.")                                                       \
 116           range(0,100)                                                      \
 117                                                                             \
 118   experimental(uintx, ShenandoahLearningSteps, 5,                           \
 119           "Number of GC cycles to run in order to learn application "       \
 120           "and GC performance for adaptive heuristics.")                    \
 121           range(0,100)                                                      \
 122                                                                             \
 123   experimental(uintx, ShenandoahImmediateThreshold, 90,                     \
 124           "If mark identifies more than this much immediate garbage "       \
 125           "regions, it shall recycle them, and shall not continue the "     \
 126           "rest of the GC cycle. The value is in percents of total "        \
 127           "number of candidate regions for collection set. Setting this "   \
 128           "threshold to 100% effectively disables this shortcut.")          \
 129           range(0,100)                                                      \
 130                                                                             \
 131   experimental(uintx, ShenandoahMergeUpdateRefsMinGap, 100,                 \
 132           "If GC is currently running in separate update-refs mode "        \
 133           "this numbers gives the threshold when to switch to "             \
 134           "merged update-refs mode. Number is percentage relative to"       \
 135           "duration(marking)+duration(update-refs).")                       \
 136                                                                             \
 137   experimental(uintx, ShenandoahMergeUpdateRefsMaxGap, 200,                 \
 138           "If GC is currently running in merged update-refs mode "          \
 139           "this numbers gives the threshold when to switch to "             \
 140           "separate update-refs mode. Number is percentage relative "       \
 141           "to duration(marking)+duration(update-refs).")                    \
 142                                                                             \
 143   experimental(uintx, ShenandoahGuaranteedGCInterval, 5*60*1000,            \
 144           "Most 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 interval to 0 disables this feature).")            \
 149                                                                             \
 150   experimental(bool, ShenandoahAlwaysClearSoftRefs, false,                  \
 151           "Clear soft references always, instead of using any smart "       \
 152           "cleanup policy. This minimizes footprint at expense of more "    \
 153           "softref churn in applications.")                                 \
 154                                                                             \
 155   experimental(bool, ShenandoahUncommit, true,                              \
 156           "Allow Shenandoah to uncommit unused memory.")                    \
 157                                                                             \
 158   experimental(uintx, ShenandoahUncommitDelay, 5*60*1000,                   \
 159           "Shenandoah would start to uncommit memory for regions that were" \
 160           " not used for more than this time. First use after that would "  \
 161           "incur allocation stalls. Actively used regions would never be "  \
 162           "uncommitted, because they never decay. Time is in milliseconds." \
 163           "Setting this delay to 0 effectively makes Shenandoah to "        \
 164           "uncommit the regions almost immediately.")                       \
 165                                                                             \
 166   experimental(bool, ShenandoahRegionSampling, false,                       \
 167           "Turns on heap region sampling via JVMStat")                      \
 168                                                                             \
 169   experimental(int, ShenandoahRegionSamplingRate, 40,                       \
 170           "Sampling rate for heap region sampling. "                        \
 171           "Number of milliseconds between samples")                         \
 172                                                                             \
 173   experimental(uintx, ShenandoahControlIntervalMin, 1,                      \
 174           "The minumum sleep interval for control loop that drives "        \
 175           "the cycles. Lower values would increase GC responsiveness "      \
 176           "to changing heap conditions, at the expense of higher perf "     \
 177           "overhead. Time is in milliseconds.")                             \
 178                                                                             \
 179   experimental(uintx, ShenandoahControlIntervalMax, 10,                     \
 180           "The maximum sleep interval for control loop that drives "        \
 181           "the cycles. Lower values would increase GC responsiveness "      \
 182           "to changing heap conditions, at the expense of higher perf "     \
 183           "overhead. Time is in milliseconds.")                             \
 184                                                                             \
 185   experimental(uintx, ShenandoahControlIntervalAdjustPeriod, 1000,          \
 186           "The time period for one step in control loop interval "          \
 187           "adjustment. Lower values make adjustments faster, at the "       \
 188           "expense of higher perf overhead. Time is in milliseconds.")      \
 189                                                                             \
 190   experimental(bool, ShenandoahCriticalControlThreadPriority, false,        \
 191           "Shenandoah control thread runs at critical scheduling priority.")\
 192                                                                             \
 193   diagnostic(bool, ShenandoahVerify, false,                                 \
 194           "Verify the Shenandoah garbage collector")                        \
 195                                                                             \
 196   diagnostic(intx, ShenandoahVerifyLevel, 4,                                \
 197           "Shenandoah verification level: "                                 \
 198           "0 = basic heap checks; "                                         \
 199           "1 = previous level, plus basic region checks; "                  \
 200           "2 = previous level, plus all roots; "                            \
 201           "3 = previous level, plus all reachable objects; "                \
 202           "4 = previous level, plus all marked objects")                    \
 203                                                                             \
 204   diagnostic(bool, ShenandoahElasticTLAB, true,                             \
 205           "Use Elastic TLABs with Shenandoah")                              \
 206                                                                             \
 207   diagnostic(bool, ShenandoahAllowMixedAllocs, true,                        \
 208           "Allow mixing mutator and collector allocations in a single "     \
 209           "region")                                                         \
 210                                                                             \
 211   experimental(uintx, ShenandoahAllocSpikeFactor, 5,                        \
 212           "The amount of heap space to reserve for absorbing the "          \
 213           "allocation spikes. Larger value wastes more memory in "          \
 214           "non-emergency cases, but provides more safety in emergency "     \
 215           "cases. In percents of total heap size.")                         \
 216           range(0,100)                                                      \
 217                                                                             \
 218   experimental(uintx, ShenandoahEvacReserve, 5,                             \
 219           "Maximum amount of free space to reserve for evacuation. "        \
 220           "Larger values make GC more aggressive, while leaving less "      \
 221           "headroom for application to allocate in. "                       \
 222           "In percents of total heap size.")                                \
 223           range(1,100)                                                      \
 224                                                                             \
 225   experimental(double, ShenandoahEvacWaste, 1.2,                            \
 226           "How much waste evacuations produce within the reserved "         \
 227           "space. Larger values make evacuations more resilient "           \
 228           "against allocation failures, at expense of smaller csets "       \
 229           "on each cycle.")                                                 \
 230           range(1.0,100.0)                                                  \
 231                                                                             \
 232   experimental(bool, ShenandoahEvacReserveOverflow, true,                   \
 233           "Allow evacuations to overflow the reserved space. "              \
 234           "Enabling it will make evacuations more resilient when "          \
 235           "evacuation reserve/waste is incorrect, at the risk that "        \
 236           "application allocations run out of memory too early.")           \
 237                                                                             \
 238   experimental(uintx, ShenandoahEvacAssist, 10,                             \
 239           "How many objects to evacuate on LRB assist path. "               \
 240           "Use zero to disable.")                                           \
 241                                                                             \
 242   experimental(bool, ShenandoahPacing, true,                                \
 243           "Pace application allocations to give GC chance to start "        \
 244           "and complete before allocation failure is reached.")             \
 245                                                                             \
 246   experimental(uintx, ShenandoahPacingMaxDelay, 10,                         \
 247           "Max delay for pacing application allocations. "                  \
 248           "Time is in milliseconds.")                                       \
 249                                                                             \
 250   experimental(uintx, ShenandoahPacingIdleSlack, 2,                         \
 251           "Percent of heap counted as non-taxable allocations during idle. "\
 252           "Larger value makes the pacing milder during idle phases, "       \
 253           "requiring less rendezvous with control thread. Lower value "     \
 254           "makes the pacing control less responsive to out-of-cycle allocs.")\
 255           range(0, 100)                                                     \
 256                                                                             \
 257   experimental(uintx, ShenandoahPacingCycleSlack, 10,                       \
 258           "Percent of free space taken as non-taxable allocations during "  \
 259           "the GC cycle. Larger value makes the pacing milder at the "      \
 260           "beginning of the GC cycle. Lower value makes the pacing less "   \
 261           "uniform during the cycle.")                                      \
 262           range(0, 100)                                                     \
 263                                                                             \
 264   experimental(double, ShenandoahPacingSurcharge, 1.1,                      \
 265           "Additional pacing tax surcharge to help unclutter the heap. "    \
 266           "Larger values makes the pacing more aggressive. Lower values "   \
 267           "risk GC cycles finish with less memory than were available at "  \
 268           "the beginning of it.")                                           \
 269           range(1.0, 100.0)                                                 \
 270                                                                             \
 271   experimental(uintx, ShenandoahCriticalFreeThreshold, 1,                   \
 272           "Percent of heap that needs to be free after recovery cycles, "   \
 273           "either Degenerated or Full GC. If this much space is not "       \
 274           "available, next recovery step would triggered.")                 \
 275           range(0, 100)                                                     \
 276                                                                             \
 277   diagnostic(bool, ShenandoahDegeneratedGC, true,                           \
 278           "Use Degenerated GC as the graceful degradation step. Disabling " \
 279           "this leads to degradation to Full GC")                           \
 280                                                                             \
 281   experimental(uintx, ShenandoahFullGCThreshold, 3,                         \
 282           "How many back-to-back Degenerated GCs to do before triggering "  \
 283           "a Full GC.")                                                     \
 284                                                                             \
 285   experimental(bool, ShenandoahImplicitGCInvokesConcurrent, false,          \
 286           "Should internally-caused GCs invoke concurrent cycles, or go to" \
 287           "stop-the-world (degenerated/full)?")                             \
 288                                                                             \
 289   diagnostic(bool, ShenandoahHumongousMoves, true,                          \
 290           "Allow moving humongous regions. This makes GC more resistant "   \
 291           "to external fragmentation that may otherwise fail other "        \
 292           "humongous allocations, at the expense of higher GC copying "     \
 293           "costs. Currently affects stop-the-world (full) cycle only.")     \
 294                                                                             \
 295   diagnostic(bool, ShenandoahOOMDuringEvacALot, false,                      \
 296           "Simulate OOM during evacuation frequently.")                     \
 297                                                                             \
 298   diagnostic(bool, ShenandoahAllocFailureALot, false,                       \
 299           "Make lots of artificial allocation failures.")                   \
 300                                                                             \
 301   diagnostic(bool, ShenandoahAlwaysPreTouch, false,                         \
 302           "Pre-touch heap memory, overrides global AlwaysPreTouch")         \
 303                                                                             \
 304   experimental(intx, ShenandoahMarkScanPrefetch, 32,                        \
 305           "How many objects to prefetch ahead when traversing mark bitmaps."\
 306           "Set to 0 to disable prefetching.")                               \
 307           range(0, 256)                                                     \
 308                                                                             \
 309   experimental(uintx, ShenandoahMarkLoopStride, 1000,                       \
 310           "How many items are processed during one marking step")           \
 311                                                                             \
 312   experimental(uintx, ShenandoahParallelRegionStride, 1024,                 \
 313           "How many regions are processed in one stride during parallel "   \
 314           "iteration.")                                                     \
 315                                                                             \
 316   experimental(size_t, ShenandoahSATBBufferSize, 1 * K,                     \
 317           "Number of entries in an SATB log buffer.")                       \
 318           range(1, max_uintx)                                               \
 319                                                                             \
 320   experimental(uintx, ShenandoahSATBBufferFlushInterval, 100,               \
 321           "Forcefully flush non-empty SATB buffers at this interval. "      \
 322           "Time is in milliseconds.")                                       \
 323                                                                             \
 324   experimental(uint, ShenandoahParallelSafepointThreads, 4,                 \
 325           "Number of parallel threads used for safepoint prolog/epilog")    \
 326                                                                             \
 327   diagnostic(bool, ShenandoahPreclean, true,                                \
 328           "Do concurrent preclean phase before final mark: process "        \
 329           "definitely alive references to avoid dealing with them during "  \
 330           "pause.")                                                         \
 331                                                                             \
 332   experimental(bool, ShenandoahSuspendibleWorkers, false,                   \
 333           "Suspend concurrent GC worker threads at safepoints")             \
 334                                                                             \
 335   diagnostic(bool, ShenandoahSATBBarrier, true,                             \
 336           "Turn on/off SATB barriers in Shenandoah")                        \
 337                                                                             \
 338   diagnostic(bool, ShenandoahKeepAliveBarrier, true,                        \
 339           "Turn on/off keep alive barriers in Shenandoah")                  \
 340                                                                             \
 341   diagnostic(bool, ShenandoahStoreValEnqueueBarrier, false,                 \
 342           "Turn on/off enqueuing of oops for storeval barriers")            \
 343                                                                             \
 344   diagnostic(bool, ShenandoahCASBarrier, true,                              \
 345           "Turn on/off CAS barriers in Shenandoah")                         \
 346                                                                             \
 347   diagnostic(bool, ShenandoahCloneBarrier, true,                            \
 348           "Turn on/off clone barriers in Shenandoah")                       \
 349                                                                             \
 350   diagnostic(bool, ShenandoahLoadRefBarrier, true,                          \
 351           "Turn on/off load-reference barriers in Shenandoah")              \
 352                                                                             \
 353   diagnostic(bool, ShenandoahConcurrentScanCodeRoots, true,                 \
 354           "Scan code roots concurrently, instead of during a pause")        \
 355                                                                             \
 356   diagnostic(uintx, ShenandoahCodeRootsStyle, 2,                            \
 357           "Use this style to scan code cache:"                              \
 358           " 0 - sequential iterator;"                                       \
 359           " 1 - parallel iterator;"                                         \
 360           " 2 - parallel iterator with cset filters;")                      \
 361                                                                             \
 362   diagnostic(bool, ShenandoahOptimizeStaticFinals, true,                    \
 363           "Optimize barriers on static final fields. "                      \
 364           "Turn it off for maximum compatibility with reflection or JNI "   \
 365           "code that manipulates final fields.")                            \
 366                                                                             \
 367   develop(bool, ShenandoahVerifyOptoBarriers, false,                        \
 368           "Verify no missing barriers in C2")                               \
 369                                                                             \
 370   diagnostic(bool, ShenandoahLoopOptsAfterExpansion, true,                  \
 371           "Attempt more loop opts after barrier expansion")                 \
 372                                                                             \
 373   diagnostic(bool, ShenandoahSelfFixing, true,                              \
 374           "Fix references with load reference barrier. Disabling this "     \
 375           "might degrade performance.")                                     \
 376 
 377 
 378 #endif // SHARE_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP