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