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