Java GC Tutorials - Herong's Tutorial Examples - v1.12, by Herong Yang
GCPerfP99V2.java - Object Number and Size
This section provides tutorials to find the work load level for the GCPerfP99V2.java program to the impact of execution environment interruptions to a very level. Work load of 1000 gives me a coefficient variation of 1.22% on my computer used in 2019.
In the last tutorial, I was able the increase the work load of my application to reduce the impact of environment interruptions to a very level.
In this tutorial, I want to increase the work load of the GC to increase its impact on my application, so that I can measure it more accurately.
Test 1 - Running GCPerfP99V2.java with the default object size and chunk size.
herong> java -XX:+UseSerialGC -Xms400m -Xmx400m -Xlog:gc \ GCPerfP99V2 1024 32 32 0 10 1000 100 Parameters: Size=1024KB, Base=32, Chunk=32, Warmup=0, Runs=10, Loads=1000 [1.197s] Run start 1 [2.352s] Run end 1: 1155ms [2.361s] Run start 2 [3.501s] Run end 2: 1149ms [3.502s] Run start 3 GC(0) Pause Young (Allocation Failure) 106M->38M(386M) 18.735ms [4.665s] Run end 3: 1164ms [4.666s] Run start 4 [5.829s] Run end 4: 1164ms [5.829s] Run start 5 [6.979s] Run end 5: 1150ms [6.98s] Run start 6 GC(1) Pause Young (Allocation Failure) 144M->74M(386M) 22.835ms [8.14s] Run end 6: 1161ms [8.14s] Run start 7 [9.268s] Run end 7: 1128ms [9.269s] Run start 8 [10.4s] Run end 8: 1132ms [10.4s] Run start 9 GC(2) Pause Young (Allocation Failure) 180M->119M(386M) 23.174ms [11.554s] Run end 9: 1154ms [11.555s] Run start 10 [12.682s] Run end 10: 1128ms Statistics of percentile runs: runs = 10 percentile = 100 P99 = 10 Total number of runs = 10 Percentile % = 100 Execution time = 11485 ms Average time per run = 1148 ms Standard deviation = 13.516656391282572 ms Objects processed = 320 Throughput = 27 objects/second Latency = 37037 ms/1000 objects Throughput (max, ave, min) = (28, 27, 27) Latency (min, ave, max) = (35714, 37037, 37037) Worst runs dropped:
As you can see, GC took 18 to 23 ms to complete, which is about the same level as other environment interruptions. So I need to increase the number of objects in the Eden for the GC to process. This can be done by decrease the object size and increase the chunk size to keep the same amount work for each run.
Test 2 - Running GCPerfP99V2.java with object size of 32K and chunk size of 1024.
herong> java -XX:+UseSerialGC -Xms400m -Xmx400m -Xlog:gc \ GCPerfP99V2 32 1024 1024 0 10 1000 100 Parameters: Size=32KB, Base=1024, Chunk=1024, Warmup=0, Runs=10, Loads=1000 [1.204s] Run start 1 [2.349s] Run end 1: 1145ms [2.358s] Run start 2 [3.496s] Run end 2: 1147ms [3.497s] Run start 3 GC(0) Pause Young (Allocation Failure) 106M->38M(386M) 19.225ms [4.651s] Run end 3: 1155ms [4.651s] Run start 4 [5.785s] Run end 4: 1134ms [5.786s] Run start 5 [6.919s] Run end 5: 1134ms [6.92s] Run start 6 GC(1) Pause Young (Allocation Failure) 145M->138M(386M) 51.666ms [8.102s] Run end 6: 1183ms [8.103s] Run start 7 [9.232s] Run end 7: 1130ms [9.232s] Run start 8 [10.365s] Run end 8: 1133ms [10.366s] Run start 9 GC(2) Pause Young (Allocation Failure) 245M->244M(386M) 51.924ms [11.55s] Run end 9: 1185ms [11.551s] Run start 10 [12.685s] Run end 10: 1135ms Statistics of percentile runs: Total number of runs = 10 Percentile % = 100 Execution time = 11481 ms Average time per run = 1148 ms Standard deviation = 19.39845354661036 ms Objects processed = 10240 Throughput = 891 objects/second Latency = 1157 ms/1000 objects Throughput (max, ave, min) = (906, 891, 864) Latency (min, ave, max) = (1103, 1122, 1157) Worst runs dropped:
With more objects, GC took 19 to 52 ms to complete now.
In conclusion, GCPerfP99V2.java provides better options to help measuring performance impact of GC.
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"
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
GCPerformance.java - GC Performance Test Program
GCPerformance.java - Program Output
Performance Impact of Wait Time
Performance Impact of Object Size
Performance Impact of Chunk Size
Performance Jumps Not Related to GC
Performance Test and System Interruptions
"START /REALTIME" - Run JVM with Highest Priority
GCPerfP99.java - 99th Percentile Performance
GCPerfP99.java - Output Verification
GCPerfP99V2.java - Percentile Performance with Load
GCPerfP99V2.java - Work Load Level
►GCPerfP99V2.java - Object Number and Size
Performance Tests on Serial Collector
Performance Tests on Parallel collector
Performance Tests on Concurrent collector
Performance Tests on G1 collector