Reputation: 12583
I'm investigating performance issues in a Java application. We've narrowed it down to periodically very expensive garbage collections. The application does very frequent YoungGen garbage collections (slightly more often than once a minute), but those are typically below 0.5 seconds. At some times, however, we encounter an hour or two where collection times are above 20 seconds, up to 160 seconds in some cases. Analysing the gc log, what seems to differ in those cases, except for the long total time, is a very much larger portion of the time being spent in kernel mode (large value of sys time).
What causes time to be spent in kernel mode? The servers are running Java 1.6.0_45, with -Xms5704m -Xmx5704m
and -XX:+UseParallelOldGC
.
Upvotes: 4
Views: 945
Reputation: 1902
It depends on whats there in your old gen. Parallel GC wont be a good candidate for a 5gb heap. if you check in visualGC, you would probably have about 1.5gb of young space, about 500mbsw of survivors and about 3.2 gb of old space.
It does take time to scavenge 3.2 gb of memory. And depending on the types of long lived objects you use in your app this time can go high. use a CMS collector that would mark and sweep concurrently. This would help in your app. if possible use these settings with CMS colelctor -XX:-UseAdaptiveSizePolicy -XX:+UseTLAB -XX:ConcGCThreads=12
These shoudl give you a good boost in your app though GC times would not mean much now as stop the world cleanup would be less.
Upvotes: 0
Reputation: 3446
With such a big heap, long Full GC's are expected. You may try to use Concurrent Mark and Sweep, as your allocation rate seems not too high (once a minute is not much).
see http://java-is-the-new-c.blogspot.de/2013/07/what-drives-full-gc-duration-its.html
and regarding ConcMarkAndSweepGC: http://java-is-the-new-c.blogspot.de/2013/07/tuning-and-benchmarking-java-7s-garbage.html
as for the question, what takes sys time. During GC there probably is interaction with kernel and the kernel memory system.
If sys times are very high, ensure no swap to disk is going on !!! Shortage of physical memory is a no go for java as the GC needs to iterate all allocated objects periodically, so if memory regions get swapped to disk, GC pauses may go into the minutes. Best is to turn off swapping at all.
Upvotes: 2