1

The problem is like this.

We are using CMS and experiencing concurrent mode failure (takes about 15 seconds). Using JRE 8.

Already using UseCMSInitiatingOccupancyOnly and CMSInitiatingOccupancyFraction (80%). Not using CMSScavengeBeforeRemark.

The allocation pattern is like this:

Lots of short-lived objects are allocated. So we are using a large young generation, 2GB. Survivor space not tuned. MaxTenuringThreshold set to 15. Every a few hours CMS kicks in.

Old generation is 4GB. Memory usage is high. After each collection, the old generation has about 30% free space. Unfortunately no more memory available. We are planning to modify the program to make it use less memory, but this takes time.

Usually the program doesn't have much work to do, but every a few hours (we can't predict when) we get really busy. And a 15-second STW is just too long.

So my question is:

How can we tune CMS for our program?

Should I increase old generation (and decrease young)?

Should I adjust Survivor?

Should I change CMSInitiatingOccupancyFraction?

Will G1GC help?

Kayaman
  • 72,141
  • 5
  • 83
  • 121
ntysdd
  • 1,206
  • 2
  • 9
  • 19
  • Have you tried +XX:+UseParallelOldGC? Given you have enough cores, it is usually better choice for small heaps. – Alexey Ragozin Sep 29 '17 at 03:31
  • @AlexeyRagozin We don't want STW at all(except for 0.x second ones). If tuning CMS is not helping, we are probably going to modify the code. – ntysdd Sep 29 '17 at 04:00
  • if all you need is sub-second pauses and have a 4GB heap then the parallel collector should be able to do that, assuming you have enough cores and not an extremely reference-heavy workload. – the8472 Sep 29 '17 at 07:28

1 Answers1

0

Old generation is 4GB. experiencing concurrent mode failure (takes about 15 seconds).

That is not exactly a large heap. If you're experiencing concurrent mode failures which are single-threaded you might as well use the parallel collector for that size.

So we are using a large young generation, 2GB.

This is comparatively huge, given the overall heap size of 4GB, you should shrink the young generation so that the old gen has more than those 30% breathing room.

Every a few hours CMS kicks in.

Then you could afford to run that more frequently by decreasing the IHOP

the8472
  • 40,999
  • 5
  • 70
  • 122
  • CMS is not a compacting collector. Won't it fragment the heap and force a STW if I allow short-lived objects to get into tenured space too easily? – ntysdd Sep 29 '17 at 02:47
  • possibly more fragmentation, but also more space capacity to deal with it – the8472 Sep 29 '17 at 07:24