1

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?

Ravindra babu
  • 37,698
  • 11
  • 250
  • 211
Lokesh Garg
  • 71
  • 1
  • 1
  • 5
  • one more thing. The machine has 256G of physical memory out of which ~200G is free ( including buffer and cache and excluding swap) – Lokesh Garg Apr 05 '16 at 21:50
  • and after setting -XX:SurvivorRatio=1 (after setting other values such as 8, 6, 5), the PS Survivor Space size just increased to 220 MB. Setting the value to 8 didnt have any effect and then setting to 6 had only margin change. – Lokesh Garg Apr 05 '16 at 22:22

2 Answers2

4

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

Ravindra babu
  • 37,698
  • 11
  • 250
  • 211
2

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.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • @4999394 I am not able to test because low Survivor Space size is causing survivor to be empty all the time while Eden is always full. so the Objects are directly moving from Eden to old Gen because of low PS Survivor Space. So I need to get PS Survivor Space right.What is puzzling me that same JVM in production is allocating much higher memory ie as per default SurvivorRatio=8. In UAT environment default SurvivorRatio is 8 but the actual ratio of Eden and Survivor is 106 (2.6G*1024/25 MB). I has set various SurvivorRatios to see the effect on SurvivorSpace but no significant increase. – Lokesh Garg Apr 06 '16 at 13:41
  • @NewMember How similar is the load in production and UAT? – Peter Lawrey Apr 06 '16 at 15:09
  • Production is very heavily loaded with around around jvm separate instances and each one has some work to do. 5 instances has heap memory allocation in my questions above. others have max heap size as 2G-4G but each instance has something to do. UAT instance is very quiet and have only 8 jvm instances. – Lokesh Garg Apr 06 '16 at 15:16
  • @NewMember The difference is load is enough to make such a difference. – Peter Lawrey Apr 06 '16 at 16:14
  • @Ravindra Thanks for your attention and valuable help. I applied -Xmn4g and -XX:SurvivorRatio=4 to achieve Eden and Survivor space sizes in UAT and able to nearly the space size comparable to Prod. Not ideal but can at least I can test. I'll try to increase number of instances in UAT and will observe and will inform. Thanks. – Lokesh Garg Apr 06 '16 at 20:50