Parallel Collector Adaptive Size Policy
This section describes the Adaptive Size Policy supported by the Parallel Collector to dynamically change heap generation sizes to latency, throughput and footprint goals sequentially.
In the last tutorial, we observed that the Parallel collector dynamically
changes Young generation size and survivor space ratio.
This behavior is actually a result of the "Adaptive Size Policy" used
by the Parallel collector. Here is how it is described in Java documentation:
1. The "Adaptive Size Policy" is turned on by default with the
Parallel collector ("-XX:+UseParallelGC" JVM option).
2. The "Adaptive Size Policy" can be turned on and off explicitly using
-XX:+UseAdaptiveSizePolicy and "-XX:-UseAdaptiveSizePolicy" JVM options.
3. If it is turned on, the "Adaptive Size Policy"
will change heap generation sizes dynamically to meet the following goals
- Latency Goal -
Reduce application pauses below a desired level.
- Throughput Goal -
Increase the ratio of application execution time over pause time above a desired level.
- Footprint Goal -
Reduce the heap size as low as possible.
4. The "Adaptive Size Policy" uses the following simple approach to meet above goals:
- Step 1 - Try to meet the Latency Goal:
Check the application pause time.
If it is greater than the desired level,
then reduce the generations sizes to reduce application pause time.
- Step 2 - Try to meet the Throughput Goal:
Check the ratio of application execution time over pause time,
if the Latency goal is being met.
If the ratio of application execution time over pause time is lower than the desired level,
then increase the generation sizes to increase application execution time.
- Step 3 - Try to meet the Footprint Goal:
If both Latency goal and Throughput goal are being met,
then generation sizes to reduce heap memory footprint.
5. The latency goal can be controlled
by the "-XX:MaxGCPauseMillis=nnn" JVM option,
where nnn specifies the number of milliseconds as the desired
the application pause time.
The default is "-XX:MaxGCPauseMillis=4294967295".
6. The throughput goal can be controlled
by the "-XX:GCTimeRatio=nnn" JVM option,
where nnn is used in a "1/(+nnn)" expression
specifing the percentage of time for application GC pauses
The default is "-XX:GCTimeRatio=99", which says
1% (or 1/(1+99)) of time should be used for application GC pauses.
7. The "-XX:AdaptiveSizePolicyOutputInterval=1"
and "PrintAdaptiveSizePolicy" JVM options
can be used to print out GC log messages
on how Adaptive Size Policy was carried out
at each GC.
The "Adaptive Size Policy" feature sounds great.
We will test it out in the next tutorials.
Table of Contents
About This Book
Heap Memory Area and Size Control
JVM Garbage Collection Logging
Introduction of Garbage Collectors
Serial Collector - "+XX:+UseSerialGC"
►Parallel Collector - "+XX:+UseParallelGC"
What Is Parallel Collector
Parallel Collector GC Log Message Format
Log Message Types from Parallel Collector
"--Xlog:gc+task+time=debug" - Print GC Threads
"-XX:ParallelGCThreads" - # of Threads
Parallel Collector Stops Application for Minor/Major GC
PSYoungGen Collector Using Tenuring Age
Parallel Collector Changing NewRatio and SurvivorRatio
►Parallel Collector Adaptive Size Policy
Adaptive Size Policy Log Messages
"-Xlog:gc+ergo=trace" - Minor GC Report
Adaptive Size Policy Changed Survivor Space
Adaptive Size Policy Changed Eden Space
Adaptive Size Policy for Best Latency
Parallel Collector Stopped using Young Generation
Adaptive Size Policy for Best Throughput
Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"
Garbage First (G1) Collector - "+XX:+UseG1GC"
The Z Garbage Collector (ZGC) - "+XX:+UseZGC"
Object References and Garbage Collection
Garbage Collection Performance Test Program
Performance Tests on Serial Collector
Performance Tests on Parallel collector
Performance Tests on Concurrent collector
Performance Tests on G1 collector
Garbage Collection Performance Test Summary
Full Version in PDF/EPUB