GC调优——XX:TargetSurvivorRatio的妙用
2017-12-27 17:41
435 查看
使用jmeter对服务进行压测,一个需要吞吐量的应用,2000个线程,JVM参数如下:
参数释义:新生代使用PS(Parallel Scavenge)收集器,老年代使用PO(Serial Old)收集器,Survivor区使用自适应策略,老年代大小为1024M,新生代大小为3072M,运行之后部分gc日志如下:
来说一说存在的问题:对象进入Survivor区之后,由于使用的是自适应策略,导致年龄为1的时候,也就是Minor GC一次的时候就被移动到老年代了,导致老年代内存增长太快,结果导致在2000线程的压力下,10分钟就发生了一次FGC:
现在修改参数如下:
重要参数释义:
运行后观察GC日志:老年代内存增量很慢很慢
-Xms4096m -Xmx4096m -Xss256K -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -Xmn3g -XX:+UseAdaptiveSizePolicy -XX:SurvivorRatio=10 -XX:TargetSurvivorRatio=80 -XX:+UseParallelGC -XX:ParallelGCThreads=16 -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -Xloggc:gclog.log
参数释义:新生代使用PS(Parallel Scavenge)收集器,老年代使用PO(Serial Old)收集器,Survivor区使用自适应策略,老年代大小为1024M,新生代大小为3072M,运行之后部分gc日志如下:
759.070: [GC (Allocation Failure) Desired survivor size 54001664 bytes, new threshold 1 (max 15) [PSYoungGen: 3077120K->38288K(3091456K)] 3364258K->329282K(4140032K), 0.0254347 secs] [Times: user=0.30 sys=0.01, real=0.02 secs] 760.813: [GC (Allocation Failure) Desired survivor size 52953088 bytes, new threshold 1 (max 15) [PSYoungGen: 3076496K->41152K(3094016K)] 3367490K->335530K(4142592K), 0.0259776 secs] [Times: user=0.31 sys=0.00, real=0.03 secs] 762.741: [GC (Allocation Failure) Desired survivor size 51904512 bytes, new threshold 1 (max 15) [PSYoungGen: 3082432K->39072K(3092992K)] 3376810K->336986K(4141568K), 0.0253653 secs] [Times: user=0.30 sys=0.00, real=0.02 secs] 764.476: [GC (Allocation Failure) Desired survivor size 51380224 bytes, new threshold 1 (max 15) [PSYoungGen: 3080352K->41472K(3095552K)] 3378266K->343266K(4144128K), 0.0259734 secs] [Times: user=0.31 sys=0.00, real=0.03 secs] 766.346: [GC (Allocation Failure) Desired survivor size 50855936 bytes, new threshold 1 (max 15) [PSYoungGen: 3086336K->39616K(3095040K)] 3388130K->344530K(4143616K), 0.0265471 secs] [Times: user=0.30 sys=0.00, real=0.03 secs]
来说一说存在的问题:对象进入Survivor区之后,由于使用的是自适应策略,导致年龄为1的时候,也就是Minor GC一次的时候就被移动到老年代了,导致老年代内存增长太快,结果导致在2000线程的压力下,10分钟就发生了一次FGC:
734.611: [Full GC (Ergonomics) [PSYoungGen: 39264K->0K(3102208K)] [ParOldGen: 1044614K->203586K(1048576K)] 1083878K->203586K(4150784K), [Metaspace: 71093K->71084K(1114112K)], 0.4044200 secs] [Times: user=1.56 sys=0.02, real=0.41 secs] 736.801: [GC (Allocation Failure)
现在修改参数如下:
-Xms4096m -Xmx4096m -Xss256K -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -Xmn3g -XX:-UseAdaptiveSizePolicy -XX:SurvivorRatio=10 -XX:TargetSurvivorRatio=80 -XX:+UseParallelGC -XX:ParallelGCThreads=16 -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -Xloggc:gclog.log
重要参数释义:
-XX:-UseAdaptiveSizePolicy 禁用Survivor区自适应策略 -XX:TargetSurvivorRatio=80 Survivor区对象使用率80%,默认是50%
运行后观察GC日志:老年代内存增量很慢很慢
423.288: [GC (Allocation Failure) [PSYoungGen: 2663744K->37488K(2883584K)] 2805561K->179425K(3932160K), 0.0249582 secs] [Times: user=0.27 sys=0.00, real=0.02 secs] 424.884: [GC (Allocation Failure) [PSYoungGen: 2658928K->39872K(2883584K)] 2800865K->181817K(3932160K), 0.0250108 secs] [Times: user=0.27 sys=0.01, real=0.03 secs] 426.367: [GC (Allocation Failure) [PSYoungGen: 2661312K->42848K(2883584K)] 2803257K->184817K(3932160K), 0.0259483 secs] [Times: user=0.30 sys=0.00, real=0.02 secs] 427.911: [GC (Allocation Failure) [PSYoungGen: 2664288K->42464K(2883584K)] 2806257K->184441K(3932160K), 0.0260695 secs] [Times: user=0.29 sys=0.01, real=0.03 secs] 429.493: [GC (Allocation Failure) [PSYoungGen: 2663904K->42960K(2883584K)] 2805881K->184961K(3932160K), 0.0264706 secs] [Times: user=0.29 sys=0.01, real=0.03 secs] 431.164: [GC (Allocation Failure) [PSYoungGen: 2664400K->44816K(2883584K)] 2806401K->186985K(3932160K), 0.0263883 secs] [Times: user=0.29 sys=0.00, real=0.03 secs] 432.723: [GC (Allocation Failure) [PSYoungGen: 2666256K->42016K(2883584K)] 2808425K->184201K(3932160K), 0.0269009 secs] [Times: user=0.29 sys=0.00, real=0.03 secs] 434.244: [GC (Allocation Failure) [PSYoungGen: 2663456K->42896K(2883584K)] 2805641K->185217K(3932160K), 0.0258802 secs] [Times: user=0.29 sys=0.01, real=0.03 secs] 435.859: [GC (Allocation Failure) [PSYoungGen: 2664336K->40608K(2883584K)] 2806657K->182937K(3932160K), 0.0253089 secs] [Times: user=0.28 sys=0.01, real=0.02 secs] 437.329: [GC (Allocation Failure) [PSYoungGen: 2662048K->42304K(2883584K)] 2804377K->184665K(3932160K), 0.0283344 secs] [Times: user=0.29 sys=0.00, real=0.02 secs]
相关文章推荐
- GC调优在Spark应用中的实践
- ognl.OgnlException: target is null for setProperty(null, "XX", [Ljava.lang.String;@10f8ee4)解决
- JVM调优:选择合适的GC collector (三)
- GC调优在Spark应用中的实践[转]
- 导入项目报错:Unable to resolve target 'android-XX'
- 深入JVM系列(二)之GC机制、收集器与GC调优
- The processing instruction target matching "[xX][mM][lL]" is not allowed.
- GC浅析之三-性能调优经验总结
- The processing instruction target matching "[xX][mM][lL]" is not allowed.
- ofbiz fop 报错 The processing instruction target matching "[xX][mM][lL]" is not allowed
- 出现 The processing instruction target matching "[xX][mM][lL]" is not allowed错误
- Multiple annotations found at this line: - The processing instruction target matching "[xX][mM][lL]" is not allowed.
- GC调优在Spark应用中的实践
- Nested exception: The processing instruction target matching "[xX][mM][lL]" is not allowed.
- Android 报错:The Processing Instruction Target Matching “[xX][mM][lL]”
- Unable to resolve target 'android-XX'
- The processing instruction target matching "[xX][mM][lL]" is n...
- 描述下jvm的gc机制,常用的jvm调优方法,oom如何产生,如何处理oom 问题?
- 6. GC 调优(工具篇) - GC參考手冊
- Java GC 专家系列3:GC调优实践