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