开发者

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

开发者 https://www.devze.com 2023-01-24 02:30 出处:网络
Currently I am facing the problem that my application is showing long GC times sporadically,开发者_如何学JAVA but all these are only caused by weak reference processing. So the thread stopped time is

Currently I am facing the problem that my application is showing long GC times sporadically,开发者_如何学JAVA 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号