How can I lower the weak ref processing time durin

2019-03-19 07:26发布

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条回答
相关推荐>>
2楼-- · 2019-03-19 08:22

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

查看更多
登录 后发表回答