Introduction

As described in JEP 248, in JDK 9 the default garbage collector will switch from Parallel Garbage Collector (Parallel GC) to G1 Garbage Collector (G1GC).

This wiki-page aims to outline the basic JVM parameters switching to G1GC, and how you can help collecting data comparing the G1GC and Parallel GC.

Usually we would like to ask for gc logs, printed  with '-XX:+PrintGCTimeStamps -XX:+PrintGCDetails'. Some time to diagnose further, we might ask for more detailed information (please see 'GC Parameters to provide more information'). We would like to focus on minimally tuned G1GC, either by not setting any flags or just setting the minimum and maximum heap size for you application and potentially a pause target for G1GC. The gc logs can be sent to public mailing list, or if you want to send privately, please contact us. Sometimes, a Java Flight Recorder recording is helpful as well.

Basic GC Parameters:

-Xms<min_heap_size> -Xmx<max_heap_size> -XX:MaxGCPauseMillis=<n> -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:<gcfile>

For performance purpose, we usually set -Xms and -Xmx the same.  But it is ok to set them the different value.  If not set, the JVM will set those ergonomically.

MaxGCPauseMillis is important for G1GC. It determines the young gen size.  The default is 200ms.

PrintGCTimeStamps is important for gc log analysis.

PrintGCDetails provides how pause time is distributed among gc steps.

loggc provides a way to write gc logs to a separate file, instead of stout. We recommend to do so.

GC Parameters to provide more information

If you experience any bad behavior (or if things run well) we might need further data to be able to do a more in-depth analysis to determine the cause of any issue. These flags might impact performance due to the fact that they collect more and extensive low-level data. 

-XX:+PrintAdaptiveSizePolicy

This flag provides information about how g1 Ergonomics decides young gen size, when to start marking cycle, etc.

-XX:+PrintHeapAtGC

Print heap layout before and after gc.

-XX:+PrintTenuringDistribution

Print the age distribution among the objects in young gen.

-XX:+UnlockExperimentalVMOptions -XX:G1LogLevel=finest

This flag prints more detailed information, for example, pause time per gc thread.

-XX:+UnlockDiagnosticVMOptions -XX:+G1PrintRegionLivenessInfo

This flag prints liveness of each region before and after sorting at the end of marking cycle.

-XX:+UnlockDiagnosticVMOptions  -XX:G1SummarizeRSetStats -XX:G1SummarizeRSetStatsPeriod=<n>

This flag prints out remember set statistics, every n gc cycles.

-XX:+UnlockDiagnosticVMOptions -XX:+G1SummarizeConcMark

This flag summarize concurrent marking information.

-XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime

Print time when application is stopped due to safe points, and the time the application executes in between.

For how to understand the gc logs, please refer to blogs about how to print and understand basik G1GC logs.

For how to understand the printGCAdaptiveSizePolicy, please refer to blogs about how to understand G1GC ergonomics.

What to collect 


We would like to get your feedback on all experiences, good, neutral and bad. Usually bad experiences is what generates blogs and emails, the other data points are not always easy to get. 

Metrics
The following we see as the key metrics to gather data around to determine the impact of the switch. Not all metrics will be interesting for every application, but a default collector needs to behave well in them as a whole. 

Applications
We are focusing on general Java applications, and not on applications that are very dependent on extreme GC tuning. Applications not considered a target for this switch includes applications requiring low latency with milliseconds, micro or no-pause requirements, nor very large heap applications that use multiple of 10s or 100s of GB  live data. The focus is on applications that are normally not tuned, either because there has never been a need to do so or they are used by people not accustomed to GC tuning.

For these applications all the metrics apply, but their importance vary from workload to workload.

Java Flight Recorder

Java Flight Recorder(JFR) is a commercial feature that provides java process profiles. Here is a link to Oracle document about JFR.

Here is another helpful blog.

Where to ask questions and share data

Please send your questions and data to hotspot-gc-use@openjdk.java.net or hotspot-gc-dev@openjdk.java.net

If you prefer to send your log in private, you can send emails to yu.zhang@oracle.com. We will find a way that works for both parties.

Where can I see what has been collected and analyzed

We will create sub-pages to this wikipage where you will be able to find different workloads, their performance and behavior with G1. 

Where to get JDK 9 early access build with G1GC as default

from JDK 9 Out Reach Page