简体   繁体   English

如何减少Java GC年轻大小的暂停时间

[英]How To Decrease Java GC Young Size Pause Time

I am trying to write Java program to understand gc optimization. 我正在尝试编写Java程序来了解gc优化。 I am newbie in java. 我是Java的新手。 The program read huge partitons key from cassandra concurrently, let's say 2 parallelism. 该程序同时从cassandra中读取了巨大的partitons密钥,比方说2并行性。 After reading, i have nothing to do with the rows. 看完后,我与行无关。 They will be waiting GC. 他们将在等待GC。 After reading 6 partition key, First GC runs and takes 10 seconds. 读取6个分区键后,First GC运行并耗时10秒。 In my opinion, first 4 partition key are being removed. 我认为,前四个分区键已被删除。

My problem is, 10 seconds gc pause two much, i use GC setting like below. 我的问题是,10秒gc暂停了两个,我使用如下的GC设置。 Is there any suggestion? 有什么建议吗?

java -Dcom.sun.management.jmxremote \
  -Dcom.sun.management.jmxremote.port=9010 \
  -Dcom.sun.management.jmxremote.local.only=false \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -Dcom.sun.management.jmxremote.ssl=false \
  -Xms24g \
  -Xmx24g \
  -XX:+PrintGC \
  -XX:+UseG1GC \
  -XX:MaxGCPauseMillis=200 \
  -XX:G1HeapRegionSize=6 \
  -XX:ParallelGCThreads=12 \
  -XX:ConcGCThreads=4 \
  -XX:+UnlockExperimentalVMOptions \
  -XX:G1NewSizePercent=70 \
  -XX:G1MaxNewSizePercent=80 \
  -XX:InitiatingHeapOccupancyPercent=30 \
  -jar mapreducer-1.0-SNAPSHOT.jar

In theory, the way to reduce GC pause times for young-space collections is to reduce the young / new space size. 从理论上讲,减少年轻空间集合的GC暂停时间的方法是减小新空间的大小。

In fact, these options: 实际上,这些选项:

  -XX:G1NewSizePercent=70 \
  -XX:G1MaxNewSizePercent=80 \

are forcing the young space to be between 70% and 80% of the total heap size. 迫使年轻空间在总堆大小的70%到80%之间。 That is probably why the GC is unable to meet the goal specified by this: 这可能是GC无法达到此指定目标的原因:

  -XX:MaxGCPauseMillis=200 \

The young space need to be a lot smaller. 年轻的空间需要小很多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM