Lokesh Garg
Lokesh Garg

Reputation: 71

Why JVM calculated PS Survivor Space size too low for parallel collector

I am using JDK1.6.0_16 JVM for the java application that is hosted on an Linux Intel procesor 80 cores machine.

while starting the Java application I have only two options configured -Xms2048m -Xmx8000m in the JVM Options (after java command). I see that PS Old Gen is calculated as 5.21G and PS Eden is calcuated 2.6G but the PS Survivor space is 25MB.

I have exactly same JVM in production and in that PS Survivor Space size is shown as 888MB. I am seeing these sizes in java mission control Memory tab. The cache size (output of /proc/cpuinfo) is showing 24656 in both UAT and production boxes.

Dont think it will make any difference for JVM but still mentioning that the there was very low load on machine at the time of starting JVM.

Can you please advise what parameters does JVM consider for calculating the PS Survivor Space size?

Upvotes: 1

Views: 14368

Answers (2)

Ravindra babu
Ravindra babu

Reputation: 38910

From oracle gc tuning article 1 and article 2 :

Survivor Space Sizing

You can use the parameter SurvivorRatio can be used to tune the size of the survivor spaces, but this is often not important for performance. For example, -XX:SurvivorRatio=6 sets the ratio between eden and a survivor space to 1:6.

In other words, each survivor space will be one-sixth the size of eden, and thus one-eighth the size of the young generation (not one-seventh, because there are two survivor spaces).

If survivor spaces are too small, copying collection overflows directly into the tenured generation. If survivor spaces are too large, they will be uselessly empty.

The NewSize and MaxNewSize parameters control the new generation’s minimum and maximum size. Regulate the new generation size by setting these parameters equal. The bigger the younger generation, the less often minor collections occur.

NewRatio: The size of the young generation relative to the old generation is controlled by NewRatio. For example, setting -XX:NewRatio=3 means that the ratio between the old and young generation is 1:3, the combined size of eden and the survivor spaces will be fourth of the heap.

As correctly quoted by Peter Lawrey, setting survivor depends on type of your application. From gc tuning article by Oracle, here are the guidelines.

  1. First decide the maximum heap size you can afford to give the virtual machine. Then plot your performance metric against young generation sizes to find the best setting

  2. If the total heap size is fixed, then increasing the young generation size requires reducing the tenured generation size. Keep the tenured generation large enough to hold all the live data used by the application at any given time, plus some amount of slack space (10 to 20% or more).

  3. Subject to the previously stated constraint on the tenured generation: Grant plenty of memory to the young generation and increase the young generation size as you increase the number of processors, because allocation can be parallelized. The default is calculated from NewRatio and the -Xmx setting

Upvotes: 4

Peter Lawrey
Peter Lawrey

Reputation: 533442

Can you please advise what parameters does JVM consider for calculating the PS Survivor Space size?

It must large enough to never actually fill up after a collection of the Eden space, otherwise you will get Full GCs which is undesirable.

What is an optimal Survivor space size depends on your application. I suggest you test you application under realistic loads with a larger Eden and Survivor space than you imagine useful and see how much of that space ever gets used and add 50% to 100% based on what you see is used.

The machine has 256G of physical memory out of which ~200G

The default heap size is 32 GB and I suggest you use this default unless you have a good reason to reduce it.

-XX:SurvivorRatio=1

This is usually a bad idea and having a high survivor ratio like 8 is usually better.

Setting the value to 8 didnt have any effect

Most likely you have a low allocation rate. I usually set a high Young space, alike -Xmn8g or even -Xmn24g but whether this is a good/bad idea depends on your application.

Upvotes: 2

Related Questions