G1 日志解析

本文介绍了G1垃圾收集器的GC日志,重点解析了Desired survivor size和对象年龄的概念。日志显示动态年龄阈值为1(最大8),表明JVM会动态调整对象晋升老年代的条件。Desired survivor size表示期望的Survivor区大小,可通过-XX:TargetSurvivorRatio进行设置。日志中还展示了不同类型的GC暂停,如(young)和(mix),并举例说明了年龄为1的对象所占用的内存大小。
摘要由CSDN通过智能技术生成

G1 GC 日志

2020-04-08T13:37:57.402+0800: 317780.856: Application time: 1.7859709 seconds
2020-04-08T13:38:00.137+0800: 317783.591: Application time: 2.7316155 seconds
{Heap before GC invocations=54601 (full 2):
 garbage-first heap   total 12582912K, used 7858402K [0x00000004c0000000, 0x00000004c0803000, 0x00000007c0000000)
  region size 8192K, 122 young (999424K), 16 survivors (131072K)
 Metaspace       used 173730K, capacity 186222K, committed 186368K, reserved 1216512K
  class space    used 17662K, capacity 19184K, committed 19200K, reserved 1048576K
2020-04-08T13:38:00.141+0800: 317783.595: [GC pause (G1 Evacuation Pause) (young)
Desired survivor size 67108864 bytes, new threshold 1 (max 8)
- age   1:  133934832 bytes,  133934832 total
, 0.1140744 secs]
   [Parallel Time: 110.4 ms, GC Workers: 5]
      [GC Worker Start (ms): Min: 317783595.6, Avg: 317783595.6, Max: 317783595.7, Diff: 0.1]
      [Ext Root Scanning (ms): Min: 2.6, Avg: 2.9, Max: 3.3, Diff: 0.6, Sum: 14.5]
      [Update RS (ms): Min: 11.2, Avg: 11.6, Max: 11.8, Diff: 0.6, Sum: 58.1]
         [Processed Buffers: Min: 180, Avg: 198.0, Max: 209, Diff: 29, Sum: 990]
      [Scan RS (ms): Min: 10.7, Avg: 10.8, Max: 10.8, Diff: 0.1, Sum: 53.8]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 84.7, Avg: 85.0, Max: 85.1, Diff: 0.4, Sum: 424.9]
      [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.0, Sum: 0.1]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [GC Worker Total (ms): Min: 110.3, Avg: 110.3, Max: 110.3, Diff: 0.0, Sum: 551.5]
      [GC Worker End (ms): Min: 317783705.9, Avg: 317783705.9, Max: 317783705.9, Diff: 0.0]
   [Code Root Fixup: 0.3 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.2 ms]
   [Other: 3.2 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 1.1 ms]
      [Ref Enq: 0.1 ms]
      [Redirty Cards: 0.3 ms]
      [Humongous Reclaim: 0.2 ms]
      [Free CSet: 0.2 ms]
   [Eden: 848.0M(848.0M)->0.0B(904.0M) Survivors: 128.0M->72.0M Heap: 7674.2M(12.0G)->6722.0M(12.0G)]
Heap after GC invocations=54602 (full 2):
 garbage-first heap   total 12582912K, used 6883374K [0x00000004c0000000, 0x00000004c0803000, 0x00000007c0000000)
  region size 8192K, 9 young (73728K), 9 survivors (73728K)
 Metaspace       used 173730K, capacity 186222K, committed 186368K, reserved 1216512K
  class space    used 17662K, capacity 19184K, committed 19200K, reserved 1048576K
}
 [Times: user=0.56 sys=0.00, real=0.11 secs] 
2020-04-08T13:38:00.958+0800: 317784.412: Application time: 0.7025791 seconds
2020-04-08T13:38:02.962+0800: 317786.416: Application time: 2.0001849 seconds

Desired survivor size 67108864 bytes, new threshold 1 (max 8) 分析:

-XX:+PrintTenuringDistribution 开启动态年龄日志   

-XX:MaxTenuringThreshold=8 设置的是年龄阈值,默认15(注意JVM是动态调整)实际值参考gc日志中的  new threshold 1 (max 8)

jvm是动态对对象年龄判定的,对象年龄指的是从Eden移到survivor区后 每一次minor gc年龄加1 。

源码参考:ageTable.cpp

uint AgeTable::compute_tenuring_threshold(size_t desired_survivor_size) {
  uint result;

  if (AlwaysTenure || NeverTenure) {
    assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
           "MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
    result = MaxTenuringThreshold;
  } else {
    size_t total = 0;
    uint age = 1;
    assert(sizes[0] == 0, "no objects with age zero should be recorded");
    while (age < table_size) {
      total += sizes[age];
      // check if including objects of age 'age' made us pass the desired
      // size, if so 'age' is the new threshold
      if (total > desired_survivor_size) break;
      age++;
    }
    result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
  }

源码解析 :

AlwaysTenure 标示设置的gc参数 全部晋升到老年代,neverTenure表示全部在年轻代。

desired_survivor_size表示 survivor目标使用率,默认是50 可通过参数-XX:TargetSurvivorRatio 设置

总结:

(G1 Evacuation Pause) (young) 表示发生在young区的gc (mix) 表示mix gc

Desired survivor size 67108864 bytes, new threshold 1 (max 8)  表示期望的(还需要的)survivor大小为 67108864 bytes

动态对象年龄为1 设置的最大值8.

- age   1:  133934832 bytes,  133934832 total 日志表示的对象年龄为1的对象占用的大小。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Run_Tortoise

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值