1 /*
   2  * Copyright (c) 2016, Red Hat, Inc. and/or its affiliates.
   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                          range, \
  39                          constraint, \
  40                          writeable) \
  41                                                                             \
  42   product(bool, UseShenandoahGC, false,                                     \
  43           "Use the Shenandoah garbage collector")                           \
  44                                                                             \
  45   product(bool, ShenandoahOptimizeStaticFinals, true,                       \
  46           "Optimize barriers on static final fields. "                      \
  47           "Turn it off for maximum compatibility with reflection or JNI "   \
  48           "code that manipulates final fields.")                            \
  49                                                                             \
  50   product(bool, ShenandoahOptimizeInstanceFinals, false,                    \
  51           "Optimize barriers on final instance fields."                     \
  52           "Turn it off for maximum compatibility with reflection or JNI "   \
  53           "code that manipulates final fields.")                            \
  54                                                                             \
  55   product(bool, ShenandoahOptimizeStableFinals, false,                      \
  56           "Optimize barriers on stable fields."                             \
  57           "Turn it off for maximum compatibility with reflection or JNI "   \
  58           "code that manipulates final fields.")                            \
  59                                                                             \
  60   product(size_t, ShenandoahHeapRegionSize, 0,                              \
  61           "Size of the Shenandoah regions. "                                \
  62           "Determined automatically by default.")                           \
  63                                                                             \
  64   experimental(size_t, ShenandoahMinRegionSize, 256 * K,                    \
  65           "Minimum heap region size. ")                                     \
  66                                                                             \
  67   experimental(size_t, ShenandoahMaxRegionSize, 32 * M,                     \
  68           "Maximum heap region size. ")                                     \
  69                                                                             \
  70   experimental(intx, ShenandoahHumongousThreshold, 100,                     \
  71           "How large should the object be to get allocated in humongous "   \
  72           "region, in percents of heap region size. This also caps the "    \
  73           "maximum TLAB size.")                                             \
  74           range(1, 100)                                                     \
  75                                                                             \
  76   experimental(size_t, ShenandoahTargetNumRegions, 2048,                    \
  77           "Target number of regions. We try to get around that many "       \
  78           "regions, based on ShenandoahMinRegionSize and "                  \
  79           "ShenandoahMaxRegionSizeSize. ")                                  \
  80                                                                             \
  81   product(bool, UseShenandoahMatrix, false,                                 \
  82           "Keep a connection matrix and use this to drive collection sets") \
  83                                                                             \
  84   product(bool, PrintShenandoahMatrix, false,                               \
  85           "Print connection matrix after marking")                          \
  86                                                                             \
  87   product(ccstr, ShenandoahGCHeuristics, "adaptive",                        \
  88           "The heuristics to use in Shenandoah GC. Possible values:"        \
  89           " *) adaptive - adapt to maintain the given amount of free heap;" \
  90           " *) static  -  start concurrent GC when static free heap "       \
  91           "               threshold and static allocation threshold are "   \
  92           "               tripped;"                                         \
  93           " *) passive -  do not start concurrent GC, wait for Full GC; "   \
  94           " *) aggressive - run concurrent GC continuously, evacuate "      \
  95           "               everything;"                                      \
  96           " *) connected - run partial cycles focusing on least connected " \
  97           "               regions, along with adaptive concurrent GC;"      \
  98           " *) generational - run partial cycles focusing on young regions,"\
  99           "               along with adaptive concurrent GC), "             \
 100           " *) LRU - run partial cycles focusing on old regions, along"     \
 101           "               with adaptive concurrent GC."                     \
 102           "Defaults to adaptive")                                           \
 103                                                                             \
 104   experimental(ccstr, ShenandoahUpdateRefsEarly, "adaptive",                \
 105           "Run a separate concurrent reference updating phase after"        \
 106           "concurrent evacuation. Possible values: 'on', 'off', 'adaptive'")\
 107                                                                             \
 108   product(uintx, ShenandoahRefProcFrequency, 5,                             \
 109           "How often should (weak, soft, etc) references be processed. "    \
 110           "References get processed at every Nth GC cycle. "                \
 111           "Set to 0 to disable reference processing. "                      \
 112           "Defaults to process references every 5 cycles.")                 \
 113                                                                             \
 114   product(uintx, ShenandoahUnloadClassesFrequency, 5,                       \
 115           "How often should classes get unloaded. "                         \
 116           "Class unloading is performed at every Nth GC cycle. "            \
 117           "Set to 0 to disable concurrent class unloading. "                \
 118           "Defaults to unload classes every 5 cycles.")                     \
 119                                                                             \
 120   experimental(uintx, ShenandoahFullGCThreshold, 3,                         \
 121           "How many cycles in a row to do degenerated marking on "          \
 122           "cancelled GC before triggering a full-gc"                        \
 123           "Defaults to 3")                                                  \
 124           writeable(Always)                                                 \
 125                                                                             \
 126   product_rw(uintx, ShenandoahGarbageThreshold, 60,                         \
 127           "Sets the percentage of garbage a region need to contain before " \
 128           "it can be marked for collection. Applies to "                    \
 129           "Shenandoah GC dynamic Heuristic mode only (ignored otherwise). " \
 130           "Defaults to 60%.")                                               \
 131           range(0,100)                                                      \
 132                                                                             \
 133   product_rw(uintx, ShenandoahFreeThreshold, 10,                            \
 134           "Set the percentage of free heap at which a GC cycle is started. " \
 135           "Applies to Shenandoah GC dynamic Heuristic mode only "           \
 136           "(ignored otherwise). Defaults to 10%.")                          \
 137           range(0,100)                                                      \
 138                                                                             \
 139   product_rw(uintx, ShenandoahCSetThreshold, 40,                            \
 140           "Set the approximate target percentage of the heap for the"       \
 141           "collection set. Defaults to 40%.")                               \
 142           range(0,100)                                                      \
 143                                                                             \
 144   product_rw(uintx, ShenandoahAllocationThreshold, 0,                       \
 145           "Set percentage of memory allocated since last GC cycle before "  \
 146           "a new GC cycle is started. "                                     \
 147           "Applies to Shenandoah GC dynamic Heuristic mode only "           \
 148           "(ignored otherwise). Defauls to 0%.")                            \
 149           range(0,100)                                                      \
 150                                                                             \
 151   product_rw(uintx, ShenandoahGenerationalYoungGenPercentage, 20,           \
 152              "Percentage of the heap designated as young")                  \
 153           range(0,100)                                                      \
 154                                                                             \
 155   product_rw(uintx, ShenandoahLRUOldGenPercentage, 20,                      \
 156              "Percentage of the heap designated as old")                    \
 157           range(0,100)                                                      \
 158                                                                             \
 159   product_rw(uintx, ShenandoahConnectednessPercentage, 20,                  \
 160              "Percentage of the heap designated for connectedness")         \
 161           range(0,100)                                                      \
 162                                                                             \
 163   experimental(uintx, ShenandoahMergeUpdateRefsMinGap, 100,                 \
 164                "If GC is currently running in separate update-refs mode "   \
 165                "this numbers gives the threshold when to switch to "        \
 166                "merged update-refs mode. Number is percentage relative to"  \
 167                "duration(marking)+duration(update-refs).")                  \
 168           writeable(Always)                                                 \
 169                                                                             \
 170   experimental(uintx, ShenandoahMergeUpdateRefsMaxGap, 200,                 \
 171                "If GC is currently running in merged update-refs mode "     \
 172                "this numbers gives the threshold when to switch to "        \
 173                "separate update-refs mode. Number is percentage relative "  \
 174                "to duration(marking)+duration(update-refs).")               \
 175           writeable(Always)                                                 \
 176                                                                             \
 177   experimental(uintx, ShenandoahInitFreeThreshold, 30,                      \
 178                "Initial remaining free threshold for adaptive heuristics")  \
 179           range(0,100)                                                      \
 180                                                                             \
 181   experimental(uintx, ShenandoahMinFreeThreshold, 3,                        \
 182                "Minimum remaining free threshold for adaptive heuristics")  \
 183           range(0,100)                                                      \
 184                                                                             \
 185   experimental(uintx, ShenandoahMaxFreeThreshold, 70,                       \
 186                "Maximum remaining free threshold for adaptive heuristics")  \
 187           range(0,100)                                                      \
 188                                                                             \
 189   experimental(uintx, ShenandoahImmediateThreshold, 90,                     \
 190                "If mark identifies more than this much immediate garbage "  \
 191                "regions, it shall recycle them, and shall not continue the "\
 192                "rest of the GC cycle. The value is in percents of total "   \
 193                "number of candidates for collection set. Setting this "     \
 194                "threshold to 100% effectively disables this shortcut.")     \
 195           range(0,100)                                                      \
 196                                                                             \
 197   experimental(uintx, ShenandoahGuaranteedGCInterval, 5*60*1000,            \
 198                "Adaptive and dynamic heuristics would guarantee a GC cycle "\
 199                "at least with this interval. This is useful when large idle"\
 200                " intervals are present, where GC can run without stealing " \
 201                "time from active application. Time is in milliseconds.")    \
 202                                                                             \
 203   experimental(uintx, ShenandoahHappyCyclesThreshold, 3,                    \
 204           "How many successful marking cycles before improving free "       \
 205                "threshold for adaptive heuristics")                         \
 206                                                                             \
 207   experimental(uintx, ShenandoahPartialInboundThreshold, 10,                \
 208           "Specifies how many inbound regions a region can have maximum "   \
 209           "to be considered for collection set in partial collections.")    \
 210           writeable(Always)                                                 \
 211                                                                             \
 212   experimental(uintx, ShenandoahMarkLoopStride, 1000,                       \
 213           "How many items are processed during one marking step")           \
 214                                                                             \
 215   experimental(bool, ShenandoahConcurrentScanCodeRoots, true,               \
 216           "Scan code roots concurrently, instead of during a pause")        \
 217                                                                             \
 218   experimental(bool, ShenandoahConcurrentEvacCodeRoots, false,              \
 219           "Evacuate code roots concurrently, instead of during a pause. "   \
 220           "This requires ShenandoahBarriersForConst to be enabled.")        \
 221                                                                             \
 222   experimental(uintx, ShenandoahCodeRootsStyle, 1,                          \
 223           "Use this style to scan code cache:"                              \
 224           " 0 - sequential iterator;"                                       \
 225           " 1 - parallel iterator;"                                         \
 226           " 2 - parallel iterator with filters;")                           \
 227                                                                             \
 228   experimental(uintx, ShenandoahUncommitDelay, 5*60*1000,                   \
 229            "Shenandoah would start to uncommit memory for regions that were"\
 230            " not used for more than this time. First use after that would " \
 231            "incur allocation stalls. Actively used regions would never be " \
 232            "uncommitted, because they never decay. Time is in milliseconds."\
 233            "Setting this delay to 0 effectively makes Shenandoah to "       \
 234            "uncommit the regions almost immediately.")                      \
 235                                                                             \
 236   experimental(bool, ShenandoahIdleRegions, false,                          \
 237            "Make region idle instead of uncommit.")                         \
 238                                                                             \
 239   experimental(bool, ShenandoahBarriersForConst, false,                     \
 240           "Emit barriers for constant oops in generated code, improving "   \
 241           "throughput. If no barriers are emitted, GC will need to "        \
 242           "pre-evacuate code roots before returning from STW, adding to "   \
 243           "pause time.")                                                    \
 244                                                                             \
 245   experimental(bool, ShenandoahDontIncreaseWBFreq, true,                    \
 246           "Common 2 WriteBarriers or WriteBarrier and a ReadBarrier only "  \
 247           "if the resulting WriteBarrier isn't executed more frequently")   \
 248                                                                             \
 249   experimental(bool, ShenandoahNoLivenessFullGC, true,                      \
 250           "Skip liveness counting for mark during full GC.")                \
 251                                                                             \
 252   experimental(bool, ShenandoahWriteBarrierToIR, true,                      \
 253           "Convert write barrier to IR instead of using assembly blob")     \
 254                                                                             \
 255   experimental(bool, ShenandoahWriteBarrierCsetTestInIR, true,              \
 256           "Perform cset test in IR rather than in the stub")                \
 257                                                                             \
 258   experimental(bool, ShenandoahLoopOptsAfterExpansion, true,                \
 259           "Attempt more loop opts after write barrier expansion")           \
 260                                                                             \
 261   experimental(bool, ShenandoahWriteBarrierMemBar, true,                    \
 262           "Emit write barrier with membar for concurrent change of flag")   \
 263                                                                             \
 264   experimental(bool, UseShenandoahOWST, true,                               \
 265           "Use Shenandoah work stealing termination protocol")              \
 266                                                                             \
 267   experimental(size_t, ShenandoahSATBBufferSize, 1 * K,                     \
 268           "Number of entries in an SATB log buffer.")                       \
 269           range(1, max_uintx)                                               \
 270                                                                             \
 271   experimental(int, ShenandoahRegionSamplingRate, 40,                       \
 272           "Sampling rate for heap region sampling. "                        \
 273           "Number of milliseconds between samples")                         \
 274            writeable(Always)                                                \
 275                                                                             \
 276   experimental(bool, ShenandoahRegionSampling, false,                       \
 277           "Turns on heap region sampling via JVMStat")                      \
 278            writeable(Always)                                                \
 279                                                                             \
 280   experimental(bool, ShenandoahFastSyncRoots, true,                         \
 281           "Enable fast synchronizer roots scanning")                        \
 282                                                                             \
 283   experimental(bool, ShenandoahMergeSafepointCleanup, false,                \
 284               "Do safepoint cleanup piggy-backed on thread scans")          \
 285                                                                             \
 286   experimental(uint, ParallelSafepointCleanupThreads, 0,                    \
 287           "Number of parallel threads used for safepoint cleanup")          \
 288                                                                             \
 289   experimental(bool, ShenandoahPreclean, true,                              \
 290               "Do preclean phase before final mark")                        \
 291                                                                             \
 292   experimental(bool, ShenandoahSuspendibleWorkers, false,                   \
 293               "Suspend concurrent GC worker threads at safepoints")         \
 294                                                                             \
 295   experimental(uintx, ShenandoahControlLoopInterval, 10,                    \
 296               "The sleep interval for control loop that drives the cycles. "\
 297               "Lower values would increase GC responsiveness to changing "  \
 298               "heap conditions, at the expense of higher perf overhead. "   \
 299               "Time is in milliseconds.")                                   \
 300                                                                             \
 301   diagnostic(bool, ShenandoahSATBBarrier, true,                             \
 302           "Turn on/off SATB barriers in Shenandoah")                        \
 303                                                                             \
 304   diagnostic(bool, ShenandoahConditionalSATBBarrier, false,                 \
 305           "Generate additional conc-mark-in-progress checks around SATB"    \
 306           " barrier")                                                       \
 307                                                                             \
 308   diagnostic(bool, ShenandoahKeepAliveBarrier, true,                        \
 309           "Turn on/off keep alive barriers in Shenandoah")                  \
 310                                                                             \
 311   diagnostic(bool, ShenandoahWriteBarrier, true,                            \
 312           "Turn on/off write barriers in Shenandoah")                       \
 313                                                                             \
 314   diagnostic(bool, ShenandoahWriteBarrierRB, true,                          \
 315           "Turn on/off RB on WB fastpath in Shenandoah.")                   \
 316                                                                             \
 317   diagnostic(bool, ShenandoahReadBarrier, true,                             \
 318           "Turn on/off read barriers in Shenandoah")                        \
 319                                                                             \
 320   diagnostic(bool, ShenandoahStoreValWriteBarrier, false,                   \
 321           "Turn on/off store val write barriers in Shenandoah")             \
 322                                                                             \
 323   diagnostic(bool, ShenandoahStoreValReadBarrier, true,                     \
 324           "Turn on/off store val read barriers in Shenandoah")              \
 325                                                                             \
 326   diagnostic(bool, ShenandoahCASBarrier, true,                              \
 327           "Turn on/off CAS barriers in Shenandoah")                         \
 328                                                                             \
 329   diagnostic(bool, ShenandoahAcmpBarrier, true,                             \
 330           "Turn on/off acmp barriers in Shenandoah")                        \
 331                                                                             \
 332   diagnostic(bool, ShenandoahCloneBarrier, true,                            \
 333           "Turn on/off clone barriers in Shenandoah")                       \
 334                                                                             \
 335   diagnostic(bool, ShenandoahStoreCheck, false,                             \
 336           "Emit additional code that checks objects are written to only"    \
 337           " in to-space")                                                   \
 338                                                                             \
 339   diagnostic(bool, ShenandoahVerify, false,                                 \
 340           "Verify the Shenandoah garbage collector")                        \
 341                                                                             \
 342   diagnostic(intx, ShenandoahVerifyLevel, 4,                                \
 343           "Shenandoah verification level: "                                 \
 344           "0 = basic heap checks; "                                         \
 345           "1 = previous level, plus basic region checks; "                  \
 346           "2 = previous level, plus all roots; "                            \
 347           "3 = previous level, plus all reachable objects; "                \
 348           "4 = previous level, plus all marked objects")                    \
 349                                                                             \
 350   diagnostic(bool, ShenandoahAllocationTrace, false,                        \
 351           "Trace allocation latencies and stalls. Can be expensive when "   \
 352           "lots of allocations happen, and may introduce scalability "      \
 353           "bottlenecks.")                                                   \
 354                                                                             \
 355   diagnostic(intx, ShenandoahAllocationStallThreshold, 10000,               \
 356           "When allocation tracing is enabled, the allocation stalls "      \
 357           "larger than this threshold would be reported as warnings. "      \
 358           "Time is in microseconds.")                                       \
 359                                                                             \
 360   experimental(bool, ShenandoahCommonGCStateLoads, false,                   \
 361          "Enable commonning for GC state loads in generated code.")         \
 362                                                                             \
 363   diagnostic(bool, ShenandoahAsmWB, true,                                   \
 364           "Enable/disable inline assembler write barrier code.")            \
 365                                                                             \
 366   diagnostic(bool, ShenandoahConcMarkGC, true,                              \
 367           "Enable/disable inline concurrent mark GC.")                      \
 368                                                                             \
 369   develop(bool, VerifyStrictOopOperations, false,                           \
 370           "Verify that == and != are not used on oops. Only in fastdebug")  \
 371                                                                             \
 372   develop(bool, ShenandoahVerifyOptoBarriers, false,                        \
 373           "Verify no missing barriers in c2")                               \
 374                                                                             \
 375   develop(int, ShenandoahFailHeapExpansionAfter, -1,                        \
 376           "Artificially fails heap expansion after specified times."        \
 377           "Used to verify allocation handling. Default -1 to disable it.")  \
 378                                                                             \
 379   product(bool, ShenandoahAlwaysPreTouch, false,                            \
 380           "Pre-touch heap memory, overrides global AlwaysPreTouch")         \
 381                                                                             \
 382   experimental(intx, ShenandoahMarkScanPrefetch, 32,                        \
 383           "How many objects to prefetch ahead when traversing mark bitmaps." \
 384           "Set to 0 to disable prefetching.")                               \
 385           range(0, 256)                                                     \
 386                                                                             \
 387   experimental(intx, ShenandoahAllocGCTries, 3,                             \
 388           "How many times to try to do GC on allocation failure."           \
 389           "Set to 0 to never try, and fail instead.")                       \
 390           range(0, 16)                                                      \
 391                                                                             \
 392   experimental(bool, ShenandoahHumongousMoves, true,                        \
 393           "Allow moving humongous regions. This makes GC more resistant "   \
 394           "to external fragmentation that may otherwise fail other "        \
 395           "humongous allocations, at the expense of higher GC copying "     \
 396           "costs.")                                                         \
 397                                                                             \
 398   diagnostic(bool, ShenandoahOOMDuringEvacALot, false,                      \
 399           "Simulate OOM during evacuation frequently.")                     \
 400 
 401 
 402 
 403 SHENANDOAH_FLAGS(DECLARE_DEVELOPER_FLAG, \
 404                  DECLARE_PD_DEVELOPER_FLAG,     \
 405                  DECLARE_PRODUCT_FLAG,          \
 406                  DECLARE_PD_PRODUCT_FLAG,       \
 407                  DECLARE_DIAGNOSTIC_FLAG,       \
 408                  DECLARE_EXPERIMENTAL_FLAG,     \
 409                  DECLARE_NOTPRODUCT_FLAG,       \
 410                  DECLARE_MANAGEABLE_FLAG,       \
 411                  DECLARE_PRODUCT_RW_FLAG,       \
 412                  IGNORE_RANGE,                  \
 413                  IGNORE_CONSTRAINT, \
 414                  IGNORE_WRITEABLE)
 415 
 416 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP