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