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