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