哪个 JVM Flag 设置了 G1Ergonomics 日志中提到的 GC 开销阈值?

Which JVM Flag sets the GC overhead threshold mentioned in the G1Ergonomics log?

我正在使用 G1 垃圾收集器。

您可以使用

启用自适应大小策略日志
-XX:+PrintAdaptiveSizePolicy

这是 GC 日志中的示例输出

1822.780: [G1Ergonomics (Heap Sizing) attempt heap expansion, reason: recent GC overhead higher than threshold after GC, recent GC overhead: 11.48 %, threshold: 10.00 %, uncommitted: 0 bytes, calculated expansion amount: 0 bytes (20.00 %)]

哪个 JVM 标志管理其中提到的 阈值:10.00 %

下面是一些看似相关的标志,但我尝试为其中一些设置不同的值,但日志消息没有改变。

user@host:/home/logs/cassandra$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version | egrep  "Threshold|Percent|Ratio"
     intx BackEdgeThreshold                         = 100000                              {pd product}
     intx BiasedLockingBulkRebiasThreshold          = 20                                  {product}
     intx BiasedLockingBulkRevokeThreshold          = 40                                  {product}
     intx BlockLayoutMinDiamondPercentage           = 20                                  {C2 product}
    uintx CMSIsTooFullPercentage                    = 98                                  {product}
   double CMSLargeCoalSurplusPercent                = 0.950000                            {product}
   double CMSLargeSplitSurplusPercent               = 1.000000                            {product}
    uintx CMSPrecleanThreshold                      = 1000                                {product}
    uintx CMSScheduleRemarkEdenSizeThreshold        = 2097152                             {product}
    uintx CMSScheduleRemarkSamplingRatio            = 5                                   {product}
   double CMSSmallCoalSurplusPercent                = 1.050000                            {product}
   double CMSSmallSplitSurplusPercent               = 1.100000                            {product}
    uintx CMSTriggerRatio                           = 80                                  {product}
    uintx CMSWorkQueueDrainThreshold                = 10                                  {product}
    uintx CMS_SweepTimerThresholdMillis             = 10                                  {product}
     intx CompileThreshold                          = 10000                               {pd product}
     intx G1ConcRefinementThresholdStep             = 0                                   {product}
    uintx G1ConfidencePercent                       = 50                                  {product}
    uintx G1HeapWastePercent                        = 5                                   {product}
     intx G1RSetUpdatingPauseTimePercent            = 10                                  {product}
    uintx G1ReservePercent                          = 10                                  {product}
    uintx G1SATBBufferEnqueueingThresholdPercent    = 60                                  {product}
    uintx GCLockerEdenExpansionPercent              = 5                                   {product}
    uintx GCTimeRatio                               = 99                                  {product}
    uintx IncreaseFirstTierCompileThresholdAt       = 50                                  {product}
    uintx InitialSurvivorRatio                      = 8                                   {product}
    uintx InitialTenuringThreshold                  = 7                                   {product}
    uintx InitiatingHeapOccupancyPercent            = 45                                  {product}
     intx InterpreterProfilePercentage              = 33                                  {product}
    uintx LargePageHeapSizeThreshold                = 134217728                           {product}
    uintx MarkSweepDeadRatio                        = 1                                   {product}
    uintx MaxHeapFreeRatio                          = 100                                 {manageable}
    uintx MaxMetaspaceFreeRatio                     = 70                                  {product}
    uintx MaxTenuringThreshold                      = 15                                  {product}
    uintx MinHeapFreeRatio                          = 0                                   {manageable}
     intx MinInliningThreshold                      = 250                                 {product}
    uintx MinMetaspaceFreeRatio                     = 40                                  {product}
    uintx MinSurvivorRatio                          = 3                                   {product}
    uintx NewRatio                                  = 2                                   {product}
     intx OnStackReplacePercentage                  = 140                                 {pd product}
    uintx PretenureSizeThreshold                    = 0                                   {product}
     intx ProfileMaturityPercentage                 = 20                                  {product}
    uintx StringDeduplicationAgeThreshold           = 3                                   {product}
    uintx SurvivorRatio                             = 8                                   {product}
    uintx TLABWasteTargetPercent                    = 1                                   {product}
    uintx TargetSurvivorRatio                       = 50                                  {product}
    uintx ThresholdTolerance                        = 10                                  {product}
     intx Tier0ProfilingStartPercentage             = 200                                 {product}
     intx Tier2BackEdgeThreshold                    = 0                                   {product}
     intx Tier2CompileThreshold                     = 0                                   {product}
     intx Tier3BackEdgeThreshold                    = 60000                               {product}
     intx Tier3CompileThreshold                     = 2000                                {product}
     intx Tier3InvocationThreshold                  = 200                                 {product}
     intx Tier3MinInvocationThreshold               = 100                                 {product}
     intx Tier4BackEdgeThreshold                    = 40000                               {product}
     intx Tier4CompileThreshold                     = 15000                               {product}
     intx Tier4InvocationThreshold                  = 5000                                {product}
     intx Tier4MinInvocationThreshold               = 600                                 {product}
     intx TypeProfileMajorReceiverPercent           = 90                                  {C2 product}
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

GCTimeRatio 是您要查找的那个,当您实际指定 G1 时它具有不同的默认值。通常 PringFlagsFinal 应该附加到您的 实际命令行 因为一些标志会影响其他人的默认值。

是什么驱动 GC ergonomics is covered in the official docs,您应该在开始 GC 调优之前阅读它们。