Profile Image
rakesh

Need recommendation to optimize the metaspace value in G1GC setting

Hi Team,

As based on your recommendation on my last question we have increased the metaspace size from -XX:MetaspaceSize=256m to -XX:MetaspaceSize=512m. But still we are seeing very long pauses and frequency of pauses is very high in day time (Business hours). can you please do the analysis of this report and share your recommendation.

 

Regards 

Rakesh



Report URL - https://gceasy.io/my-gc-report.jsp?p=c2hhcmVkLzIwMjEvMDIvMjAvLS1nY19sb2dfMjBmZWIxMTU1XzEubG9nLS0xLTM5LTI3&channel=WEB

  • metaspace

  • gclongpause

Please Sign In or to post your comment or answer

Profile Image

rakesh

Hi Team,

In the metaspace graph couple of times metaspace size is not changed after GC.

I am also attaching the realtime visual snapshot of the server.

 

 

Please shae your recommendation.

your help will be highly appreciated.

 

Regards

Rakesh

 

Profile Image

Ram Lakshmanan

Hello Rakesh!

 

 In this run also GC events caused by 'Last ditch collection' and 'Metadata GC Threshold' hasn't decreased to the extent we were hoping to see:

 

 

I did take close look at your JVM arguments and I think I found the reason. Your are passing '-XX:CompressedClassSpaceSize=528482304' i.e. 504mb. On the other hand you are also passing '-XX:MaxMetaspaceSize=536870912' i.e., 512mb. 

 

'CompressedClassSpace' is a region in 'Metaspace'. For more details refer to this article. As per your application configuration 'CompressedClassSpaceSize' is almost the size of 'Metaspace'. This would leave very small room for non-class information. This explains why there is such high number of 'Last ditch collection' and 'Metadata GC Threshold' events. 

 

Here are my recommendations/thoughts:

 

a. Let's not pass '-XX:CompressedClassSpaceSize' JVM argument. Let JVM use the default value. 

b. Also let's not pass following arguments '-XX:+UseCompressedClassPointers', '-XX:+UseCompressedOops', '-XX:+ParallelRefProcEnabled'. Very less arguments we pass, JVM can use it's internal heuristics to meet the '-XX:MaxGCPauseMillis' goal you had set (i.e., 500 ms). 

 

 

Profile Image

rakesh

Thanks Ram,

For detail investigation of the GC report and your input.

But we are not passing these property in jvm setting:

'-XX:CompressedClassSpaceSize', XX:+UseCompressedClassPointers', '-XX:+UseCompressedOops'

 

I dont know from where these seeting coming in GC logs. Even I captured the flight recorder of the server even then this Compressed OOPs are showing there.

 

 

These are the only setting we are passing in jvm:

 

-XX:+UseG1GC
-Xms2048m
-Xmx16384m
-XX:+ParallelRefProcEnabled
-XX:+UnlockExperimentalVMOptions
-XX:+UseStringDeduplication
-XX:MaxGCPauseMillis=500
-XX:MaxMetaspaceSize=512m
-XX:MetaspaceSize=512m

-XX:+PrintGC
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails

 

Regards

Rakesh

Profile Image

Ram Lakshmanan

Hello Rakesh!



 'XX:+UseCompressedClassPointers', '-XX:+UseCompressedOops' are enabled by default under certain heap size/JVM version. So we don't have to worry about it.



 a. Try removing this '-XX:+ParallelRefProcEnabled' property, I don't know whether that is setting '-XX:CompressedClassSpaceSize=528482304'


b. Even if you don't pass '-XX:+ParallelRefProcEnabled' and but still '-XX:CompressedClassSpaceSize=528482304' is still getting passed as argument, then we will increase our metaspace size to 1GB i.e. '-XX:MaxMetaspaceSize=1g' and '-XX:MetaspaceSize=1g'. That will also cut down the  'Last ditch collection' and 'Metadata GC Threshold' GC events count

Profile Image

rakesh

Hi Ram,

Thanks for your response,

I think CompressedClassSpaceSize, UseCompressedClassPointers and UseCompressedOops are interrelated. and these property came by itself if UseCompressedOops enabled in jvm .

 

As per below link:

https://www.baeldung.com/jvm-compressed-oops

 

The oop compression is the default behavior from Java 7 onwards whenever the maximum heap size is less than 32 GB. When the maximum heap size is more than 32 GB, the JVM will automatically switch off the oop compression. So memory utilization beyond a 32 Gb heap size needs to be managed differently.

 

 

I will try to disable only the UseCompressedOops tomorrow and share the result accordingly.

 

Regards

Rakesh

 

Profile Image

rakesh

Hi Ram,

CompressedClassSpaceSize value appear in GC logs only if we set some value in MaxMetaspaceSize. I dont know how much percentage allocated to CompressedClassSpaceSize because we have setted only -XX:MaxMetaspaceSize=512m.

 

Regards

Rakesh

Profile Image

Ram Lakshmanan

Hello Rakesh! 


Almost all applications have set '-XX:MaxMetaspaceSize', but seldom I see 'CompressedClassSpaceSize' getting implicitly set. There is some other reason why 'CompressedClassSpaceSize' is set. But let's leave that point aside for now.  


Let us explicitly pass these arguments:
-XX:CompressedClassSpaceSize=512m
-XX:MaxMetaspaceSize=756m
-XX:MetaspaceSize=756m 


This is a high value, but let's start with this. If this arrests the 'Last ditch collection' and 'Metadata GC Threshold' GC count, we can lower the values as next step. I am optimistic this should make good positive impact on reducing the 'Last ditch collection' and 'Metadata GC Threshold' GC count

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • metaspace

  • gclongpause