How can I lower the weak ref processing time during GC?

我是研究僧i 提交于 2019-12-03 17:25:18

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/4101540/how-can-i-lower-the-weak-ref-processing-time-during-gc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!