2022-11-17T14:28:40.315+0800: 1956232.826: [GC (Allocation Failure) 2022-11-17T14:28:40.315+0800: 1956232.826: [ParNew:
1576103K->2817K(1769472K), 0.0241066 secs] 4197176K->2624616K(5046272K), 0.0243910 secs] [Times: user=0.04 sys=0.00, rea
l=0.03 secs]
2022-11-17T14:28:40.347+0800: 1956232.859: [GC (CMS Initial Mark) [1 CMS-initial-mark: 2621798K(3276800K)] 2648559K(5046
272K), 0.0110744 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]
2022-11-17T14:28:40.359+0800: 1956232.870: [CMS-concurrent-mark-start]
2022-11-17T14:28:45.647+0800: 1956238.159: [CMS-concurrent-mark: 5.282/5.289 secs] [Times: user=1.63 sys=0.41, real=5.28secs]
2022-11-17T14:28:45.648+0800: 1956238.159: [CMS-concurrent-preclean-start]
2022-11-17T14:28:45.671+0800: 1956238.182: [CMS-concurrent-preclean: 0.023/0.023 secs] [Times: user=0.03 sys=0.00, real=
0.03 secs]
2022-11-17T14:28:45.671+0800: 1956238.182: [CMS-concurrent-abortable-preclean-start]
2022-11-17T14:28:50.526+0800: 1956243.037: [GC (Allocation Failure) 2022-11-17T14:28:50.526+0800: 1956243.037: [ParNew2022-11-17T14:28:50.548+0800: 1956243.060: [CMS-concurrent-abortable-preclean: 1.472/4.877 secs] [Times: user=2.33 sys=0.03, real=4.87 secs]
: 1575681K->33553K(1769472K), 0.0281517 secs] 4197480K->2655355K(5046272K), 0.0284249 secs] [Times: user=0.05 sys=0.01, real=0.03 secs]
2022-11-17T14:28:50.572+0800: 1956243.083: [GC (CMS Final Remark) [YG occupancy: 78279 K (1769472 K)]2022-11-17T14:28:50.572+0800: 1956243.083: [Rescan (parallel) , 0.0115711 secs]2022-11-17T14:28:50.584+0800: 1956243.095: [weak refs processing, 0.8799103 secs]2022-11-17T14:28:51.464+0800: 1956243.975: [class unloading, 3.4124151 secs]2022-11-17T14:28:54.876+0800: 1956247.387: [scrub symbol table, 0.6587619 secs]2022-11-17T14:28:55.535+0800: 1956248.046: [scrub string table, 0.0028382 secs][1 CMS-remark: 2621801K(3276800K)] 2700081K(5046272K), 4.9762131 secs] [Times: user=0.29 sys=0.13, real=4.97 secs]
2022-11-17T14:28:55.550+0800: 1956248.061: [CMS-concurrent-sweep-start]
2022-11-17T14:28:57.959+0800: 1956250.470: [CMS-concurrent-sweep: 2.396/2.409 secs] [Times: user=2.31 sys=0.27, real=2.4
1 secs]
2022-11-17T14:28:57.959+0800: 1956250.470: [CMS-concurrent-reset-start]
2022-11-17T14:28:57.970+0800: 1956250.481: [CMS-concurrent-reset: 0.011/0.011 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
2022-11-17T14:28:40.347+0800: 1956232.859: [GC (CMS Initial Mark) [1 CMS-initial-mark: 2621798K(3276800K)] 2648559K(5046
272K), 0.0110744 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]
2022-11-17T14:28:40.359+0800: 1956232.870: [CMS-concurrent-mark-start]
2022-11-17T14:28:45.647+0800: 1956238.159: [CMS-concurrent-mark: 5.282/5.289 secs] [Times: user=1.63 sys=0.41, real=5.28secs]
2022-11-17T14:28:45.648+0800: 1956238.159: [CMS-concurrent-preclean-start]
2022-11-17T14:28:45.671+0800: 1956238.182: [CMS-concurrent-preclean: 0.023/0.023 secs] [Times: user=0.03 sys=0.00, real=
0.03 secs]
2022-11-17T14:28:45.671+0800: 1956238.182: [CMS-concurrent-abortable-preclean-start]
2022-11-17T14:28:50.526+0800: 1956243.037: [GC (Allocation Failure) 2022-11-17T14:28:50.526+0800: 1956243.037: [ParNew2022-11-17T14:28:50.548+0800: 1956243.060: [CMS-concurrent-abortable-preclean: 1.472/4.877 secs] [Times: user=2.33 sys=0.03, real=4.87 secs]
: 1575681K->33553K(1769472K), 0.0281517 secs] 4197480K->2655355K(5046272K), 0.0284249 secs] [Times: user=0.05 sys=0.01, real=0.03 secs]
2022-11-17T14:28:50.572+0800: 1956243.083: [GC (CMS Final Remark) [YG occupancy: 78279 K (1769472 K)]2022-11-17T14:28:50.572+0800: 1956243.083: [Rescan (parallel) , 0.0115711 secs]2022-11-17T14:28:50.584+0800: 1956243.095: [weak refs processing, 0.8799103 secs]2022-11-17T14:28:51.464+0800: 1956243.975: [class unloading, 3.4124151 secs]2022-11-17T14:28:54.876+0800: 1956247.387: [scrub symbol table, 0.6587619 secs]2022-11-17T14:28:55.535+0800: 1956248.046: [scrub string table, 0.0028382 secs][1 CMS-remark: 2621801K(3276800K)] 2700081K(5046272K), 4.9762131 secs] [Times: user=0.29 sys=0.13, real=4.97 secs]
2022-11-17T14:28:55.550+0800: 1956248.061: [CMS-concurrent-sweep-start]
2022-11-17T14:28:57.959+0800: 1956250.470: [CMS-concurrent-sweep: 2.396/2.409 secs] [Times: user=2.31 sys=0.27, real=2.4
1 secs]
2022-11-17T14:28:57.959+0800: 1956250.470: [CMS-concurrent-reset-start]
2022-11-17T14:28:57.970+0800: 1956250.481: [CMS-concurrent-reset: 0.011/0.011 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
GC过程中,长暂停主要是在【重新标记】阶段,日志为
2022-11-17T14:28:50.572+0800: 1956243.083: [GC (CMS Final Remark) [YG occupancy: 78279 K (1769472 K)]2022-11-17T14:28:50.572+0800: 1956243.083: [Rescan (parallel) , 0.0115711 secs]2022-11-17T14:28:50.584+0800: 1956243.095: [weak refs processing, 0.8799103 secs]2022-11-17T14:28:51.464+0800: 1956243.975: [class unloading, 3.4124151 secs]2022-11-17T14:28:54.876+0800: 1956247.387: [scrub symbol table, 0.6587619 secs]2022-11-17T14:28:55.535+0800: 1956248.046: [scrub string table, 0.0028382 secs][1 CMS-remark: 2621801K(3276800K)] 2700081K(5046272K), 4.9762131 secs] [Times: user=0.29 sys=0.13, real=4.97 secs]
发现,class unloading耗时较久为3.412s
查资料,发现类卸载阶段产生了很多的页活动,导致把cpu时间从GC线程抢走,内存页交换没有单独的监控,只能从实例io监控看了

从上面可以看到,发生GC时,实例io确实有突增
内存页交换机制在生产环境一般是禁用的,因此优化手段是关闭内存交换机制
参考资料: