Adaptive Size Policy for Best Throughput

This section provides a tutorial on how Adaptive Size Policy is used by the Parallel collector to our best Throughput goal.

In this second test, let's ask the Parallel collector to give us the best throughput performance using these JVM options:

-XX:MaxGCPauseMillis=1000
   We don't care about latency:
   You can pause application as long as 1000 ms.
 
-XX:GCTimeRatio=99
   We want the best throughput:
   Give us the smallest percent of time or < 1% (or 1/(1+99)) for GC

-Xmx1200m 
   We don't care about footprint:
   You can use as much as 1.2GB heap

Here is what we got:

C:\>\progra~1\java\jdk1.8.0\bin\java -XX:+UseParallelGC    
   -XX:MaxGCPauseMillis=1000 -XX:GCTimeRatio=99 -Xmx1200m 
   -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC
   -XX:+PrintGCApplicationStoppedTime    
   -XX:+PrintGCApplicationConcurrentTime
   -XX:AdaptiveSizePolicyOutputInterval=1
   -XX:+PrintAdaptiveSizePolicy
   -XX:+PrintFlagsFinal GarbageCollection2

[Global flags]
    uintx MaxGCPauseMillis                         := 1000
    uintx GCTimeRatio                              := 99      
    uintx MaxHeapSize                              := 1258291200  

...
9815   530055168   75843368   454211800
3.209: Application time: 0.0822132 seconds
   -- Last GC started
   
    UseAdaptiveSizePolicy actions to meet  *** throughput goal ***
                       GC overhead (%)
    Young generation:        7.63	  (attempted to grow)
    Tenured generation:      4.56	  (no change)
    Tenuring threshold: (attempted to decrease to balance GC costs) = 2
{Heap before GC invocations=67 (full 20):
 PSYoungGen      total 409344K, used 408493K [...
  eden space 409088K, 99% used [0x36800000,0x4f6eb568,0x4f780000)
  from space 256K, 0% used [0x4f7c0000,0x4f7c0000,0x4f800000)
  to   space 256K, 0% used [0x4f780000,0x4f780000,0x4f7c0000)
 ParOldGen       total 108288K, used 35072K [...

3.209: [GC (Allocation Failure) 

AdaptiveSizePolicy::update_averages:  
   survived: 0  promoted: 18874656  overflow: false
AdaptiveSizeStart: 3.215 collection: 67 
   avg_survived_padded_avg: 21537.279297  
   avg_promoted_padded_avg: 23658982.000000  
   avg_pretenured_padded_avg: 0.000000  
   tenuring_thresh: 1  target_size: 262144
PSAdaptiveSizePolicy::compute_eden_space_size limits: 
   desired_eden_size: 475627845 old_eden_size: 418906112 
   eden_limit: 418906112 cur_eden: 418906112 
   max_eden_size: 418906112 avg_young_live: 221
PSAdaptiveSizePolicy::compute_eden_space_size: 
   costs minor_time: 0.072691 major_cost: 0.045562 
   mutator_cost: 0.881747 throughput_goal: 0.990000 
   live_space: 285868917 free_space: 487063552 
   old_eden_size: 418906112 desired_eden_size: 418906112
AdaptiveSizeStop: collection: 67 

[PSYoungGen: 408493K->0K(409344K)] 
   443566K->53505K(517632K), 0.0057076 secs]
Heap after GC invocations=67 (full 20):
 PSYoungGen      total 409344K, used 0K [...
  eden space 409088K, 0% used [0x36800000,0x36800000,0x4f780000)
  from space 256K, 0% used [0x4f780000,0x4f780000,0x4f7c0000)
  to   space 256K, 0% used [0x4f7c0000,0x4f7c0000,0x4f800000)
 ParOldGen       total 108288K, used 53505K [...
}
3.215: Total time for which application threads were stopped: 0.0064606 s 
9816   530055168   474217312   55837856
...

Not too bad. The Adaptive Size Policy did an ok job:

Last update: 2018.

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

 "-XX:+PrintGCTaskTimeStamps" - Print GC Threads

 "-XX:ParallelGCThreads=n" - # 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

 "-XX:+PrintAdaptiveSizePolicy" - Minor GC Report

 Adaptive Size Policy Changed Survivor Space

 Adaptive Size Policy Changed Eden Space

 Adaptive Size Policy for Best Latency

Adaptive Size Policy for Best Throughput

 Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"

 Garbage First (G1) Collector - "+XX:+UseG1GC"

 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

 Outdated Tutorials

 References

 Full Version in PDF/EPUB