如何降低GC期间的弱引用处理时间? [英] How can I lower the weak ref processing time during GC?

查看:220
本文介绍了如何降低GC期间的弱引用处理时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我面临的问题是,我的应用程序偶尔会显示很长的GC时间,但所有这些只是由弱参考处理引起的。所以线程停止时间总是接近弱引用处理时间。所有其他GC循环时间为0.0001秒至0.200秒。

从gc.log(重新格式化):

<$ p $ [code> 10388.186:[GC [YG占有率:206547 K(306688 K)] 10388.186:[重新扫描(平行),
0.1095860秒] 10388.295:[weak refs processing,2.0799570 secs]
[1 CMS-remark:2973838K(3853568K)] 3180386K(4160256K),2.1899230 secs]
[Times:user = 2.51 sys = 0.00,real = 2.18 secs]
申请总时间线程已停止:2.1906890秒

目前我已经设置了这些设置。

  -Xms4g 
-Xmx4g
-XX:NewSize = 128m
-XX:+ UseConcMarkSweepGC
-XX:+ CMSIncrementalMode
-XX:MaxGCPauseMillis = 50
-XX:CMSInitiatingOccupancyFraction = 50
-XX:ParallelGCThreads = 16
-XX:+ DisableExplicitGC

如果我调出NewSize,最终会出现正常的GC周期。该机器有8个内核,并且不会为应用程序烧尽多少cpu。尝试早期和同时运行旧gen GC。

是的,我无法摆脱弱ref的用法,因为这是第三方库的一部分。

解决方案

我发现这条消息在hotspot-gc-use邮件列表中。

简而言之,请尝试 -XX:+ ParallelRefProcEnabled 开关。






更新



我在Jon Masamitsu的 $ b

p>

对于使用 参考 广泛的对象,G处理引用对象的C工作可能很明显。它在低停顿收集器中并不一定比在其他收集器中更坏,但它会更多伤害(因为我们试图保持较低的停顿)。并行参考处理可用于低暂停收集器,但默认情况下未启用。除非有大量参考对象,否则连续进行参考处理通常会更快。如果大量使用参考对象(大多数应用程序不需要),请将其打开并使用 -XX:+ ParallelRefProcEnabled T)。



Currently I am facing the problem that my application is showing long GC times sporadically, but all these are only caused by weak reference processing. So the thread stopped time is always close to the weak ref processing time. All other GC cycles are 0.0001 sec to 0.200 sec.

From the gc.log (reformatted):

10388.186: [GC[YG occupancy: 206547 K (306688 K)]10388.186: [Rescan (parallel) , 
 0.1095860 secs]10388.295: [weak refs processing, 2.0799570 secs] 
 [1 CMS-remark:  2973838K(3853568K)] 3180386K(4160256K), 2.1899230 secs] 
 [Times: user=2.51 sys=0.00, real=2.18 secs]
Total time for which application threads were stopped: 2.1906890 seconds

Currently I have these settings in place. Tried simpler settings, but no change.

-Xms4g
-Xmx4g
-XX:NewSize=128m
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:MaxGCPauseMillis=50
-XX:CMSInitiatingOccupancyFraction=50
-XX:ParallelGCThreads=16
-XX:+DisableExplicitGC

If I turn up NewSize, I end up with long normal GC cycles. The machine has 8 cores and does not burn that much cpu for the application. Tried to get to run the old gen GC early and concurrently.

And yes, I cannot get rid off the weak ref usage, because this is part of a 3rd party library.

解决方案

I found this message in the "hotspot-gc-use" mailing list.

In short, try the -XX:+ParallelRefProcEnabled switch.


UPDATE

I found a better explanation in Jon Masamitsu's Weblog:

6) Parallel reference processing in the low pause collector.

For an application that uses Reference objects extensively, the GC work to process the Reference objects can be noticeable. It's not necessarily worse in the low pause collector than in the other collects, but it hurts more (because we're trying to keep the pauses low). Parallel reference processing is available for the low pause collector but is not on by default. Unless there are tons of Reference Objects, doing the reference processing serially is usually faster. Turn it on with the flag -XX:+ParallelRefProcEnabled if you make extensive use of Reference Objects (most applications don't).

这篇关于如何降低GC期间的弱引用处理时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆