Java GC Tutorials - Herong's Tutorial Examples - v1.12, by Herong Yang
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:
java -XX:+UseParallelGC -XX:MaxGCPauseMillis=1000 -XX:GCTimeRatio=99 -Xmx1200m -XX:AdaptiveSizePolicyOutputInterval=1 -Xlog:gc=debug,gc+heap=debug,gc+ergo=trace GarbageCollection2 ... Full after scavenge average_promoted 27943460 padded_average_promoted 31022564 free in old gen 13399408 GC(39) Heap before GC invocations=40 (full 10): PSYoungGen total 403968K, used 5120K [... GC(39) eden space 398336K, 0% used [... GC(39) from space 5632K, 90% used [... GC(39) to space 5632K, 0% used [... GC(39) ParOldGen total 156160K, used 143074K [... GC(39) object space 156160K, 91% used [... ... GC(39) PSYoungGen: 5120K->0K(403968K) GC(39) ParOldGen: 143074K->32480K(161280K) GC(39) Pause Full (Ergonomics) 144M->31M(552M) 7.945ms GC(39) Heap after GC invocations=40 (full 10): PSYoungGen total 403968K, used 0K [... GC(39) eden space 398336K, 0% used [... GC(39) from space 5632K, 0% used [... GC(39) to space 5632K, 0% used [... GC(39) ParOldGen total 161280K, used 32480K [... GC(39) object space 161280K, 20% used [... GC(39) UseAdaptiveSizePolicy actions to meet *** throughput goal *** GC(39) GC overhead (%) GC(39) Young generation: 14.39 (attempted to grow) GC(39) Tenured generation: 4.93 (attempted to grow) GC(39) Tenuring threshold: (attempted to decrease to balance GC costs) = 1 9853 578813952 544504864 34309088 ...
Not too bad. The Adaptive Size Policy did an ok job:
Table of Contents
Heap Memory Area and Size Control
JVM Garbage Collection Logging
Introduction of Garbage Collectors
Serial Collector - "+XX:+UseSerialGC"
►Parallel Collector - "+XX:+UseParallelGC"
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