性能问答>想问问G1 GC中 jdk8 Humongous Total和 jdk11中的Humongous regions统计方法是不是不同.>
1回复
1年前

想问问G1 GC中 jdk8 Humongous Total和 jdk11中的Humongous regions统计方法是不是不同.



程序启动的时候由于布隆过滤器的原因会分配巨型对象.
跑在jdk 8的时候可以看到程序巨型对象占了323, 堆的occupancy和 回收后heap中的显示对不上.

但是跑在java11 一样的参数,巨型对象占的847,堆的使用量也更合理.

因此想问问它们的计算方法是不同的吗

java 8

117.677: [GC concurrent-root-region-scan-start]
117.677: [GC concurrent-root-region-scan-end, 0.0000300 secs]
117.677: [GC concurrent-mark-start]
 117.677: [G1Ergonomics (Heap Sizing) attempt heap expansion, reason: allocation request failed, allocation request: 4194320 bytes] #内存分配失败
 117.677: [G1Ergonomics (Heap Sizing) expand the heap, requested expansion amount: 16777216 bytes, attempted expansion amount: 16777216 bytes]
 117.677: [G1Ergonomics (Heap Sizing) did not expand the heap, reason: heap already fully expanded]
117.677: [Full GC (Allocation Failure) 117.726: [SoftReference, 0 refs, 0.0000327 secs]117.726: [WeakReference, 286 refs, 0.0000085 secs]117.726: [FinalReference, 381 refs, 0.0000201 secs]117.726: [PhantomReference, 0 refs, 100 refs, 0.0000049 secs]117.726: [JNI Weak Reference, 0.0000061 secs] 13G->10148M(18G), 0.1424952 secs]
   [Eden: 0.0B(912.0M)->0.0B(912.0M) Survivors: 0.0B->0.0B Heap: 13.0G(18.0G)->10148.0M(18.0G)], [Metaspace: 20898K->20898K(1069056K)]
 [Times: user=0.16 sys=0.00, real=0.14 secs]
117.820: [GC concurrent-mark-abort]
120.505: [GC pause (G1 Evacuation Pause) (young)
Desired survivor size 67108864 bytes, new threshold 15 (max 15)
 120.505: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 484, predicted base time: 1.49 ms, remaining time: 198.51 ms, target pause time: 200.00 ms]
 120.505: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 57 regions, survivors: 0 regions, predicted young region time: 20.77 ms]
 120.505: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 57 regions, survivors: 0 regions, old: 0 regions, predicted pause time: 22.26 ms, target pause time: 200.00 ms]
120.534: [SoftReference, 0 refs, 0.0000398 secs]120.534: [WeakReference, 3 refs, 0.0000048 secs]120.534: [FinalReference, 129 refs, 0.0000795 secs]120.534: [PhantomReference, 0 refs, 0 refs, 0.0000041 secs]120.534: [JNI Weak Reference, 0.0000080 secs] 120.535: [G1Ergonomics (Concurrent Cycles) request concurrent cycle initiation, reason: occupancy higher than threshold, occupancy: 16542334976 bytes, allocation request: 0 bytes, threshold: 8697308760 bytes (45.00 %), source: end of GC]
, 0.0301156 secs] #这里显示堆已经使用occupancy: 16542334976 bytes
   [Parallel Time: 28.9 ms, GC Workers: 13]
...
   [Code Root Fixup: 0.0 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.2 ms]
   [Other: 1.0 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 0.3 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.1 ms]
         [Parallel Redirty:  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
          Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
         [Redirtied Cards:  252  35  0  0  0  0  0  0  0  0  0  0  0
          Min: 0, Avg: 22.1, Max: 252, Diff: 252, Sum: 287]
      [Humongous Register: 0.3 ms]
         [Humongous Total: 323] #巨型对象占的region 323
         [Humongous Candidate: 323]
      [Humongous Reclaim: 0.1 ms]
         [Humongous Reclaimed: 0]
      [Free CSet: 0.0 ms]
         [Young Free CSet: 0.0 ms]
         [Non-Young Free CSet: 0.0 ms]
   [Eden: 912.0M(912.0M)->0.0B(784.0M) Survivors: 0.0B->128.0M Heap: 10.8G(18.0G)->10.5G(18.0G)]  #这里显示堆使用量`10.8G(18.0G)->10.5G(18.0G)`,远小于上面的occupancy: 16542334976 bytes
 [Times: user=0.38 sys=0.01, real=0.03 secs]
 121.768: [G1Ergonomics (Concurrent Cycles) initiate concurrent cycle, reason: concurrent cycle initiation requested]

java 11

[65156.755s][info][gc,task        ] GC(241) Using 13 workers of 13 for full compaction
[65156.756s][info][gc,start       ] GC(241) Pause Full (G1 Evacuation Pause)
[65156.772s][info][gc,phases,start] GC(241) Phase 1: Mark live objects
[65156.776s][info][gc,stringtable ] GC(241) Cleaned string and symbol table, strings: 9168 processed, 0 removed, symbols: 51814 processed, 0 removed
[65156.776s][info][gc,phases      ] GC(241) Phase 1: Mark live objects 3.135ms
[65156.776s][info][gc,phases,start] GC(241) Phase 2: Prepare for compaction
[65156.781s][info][gc,phases      ] GC(241) Phase 2: Prepare for compaction 5.798ms
[65156.781s][info][gc,phases,start] GC(241) Phase 3: Adjust pointers
[65156.787s][info][gc,phases      ] GC(241) Phase 3: Adjust pointers 5.837ms
[65156.787s][info][gc,phases,start] GC(241) Phase 4: Compact heap
[65156.824s][info][gc,phases      ] GC(241) Phase 4: Compact heap 36.378ms
[65156.827s][info][gc,heap        ] GC(241) Eden regions: 0->0(57)
[65156.827s][info][gc,heap        ] GC(241) Survivor regions: 0->0(8)
[65156.827s][info][gc,heap        ] GC(241) Old regions: 305->116
[65156.827s][info][gc,heap        ] GC(241) Humongous regions: 847->847 #巨型对象占的region 847
[65156.827s][info][gc,metaspace   ] GC(241) Metaspace: 24670K->24670K(1073152K)
[65156.827s][info][gc             ] GC(241) Pause Full (G1 Evacuation Pause) 18116M->15024M(18432M) 71.680ms
[65156.827s][info][gc,cpu         ] GC(241) User=0.73s Sys=0.00s Real=0.07s
2701 阅读
请先登录,再评论

jdk11默认也是用的G1,感觉不会有什么区别,从上面日志来看,在Humongous对象分配之前,会检测到old generation 使用占比是否超过了 initiating heap occupancy percent(45%),所以我猜测这里的occupancy:16542334976是old + Humongous的总的region所占用的大小,其中某些region可能并未完全使用,所以和后面的Heap: 10.8G(18.0G)->10.5G(18.0G)]有偏差

11年前