Parallel Garbage Collection in Java

parallelgc n.w
1 / 13
Embed
Share

Delve into the intricacies of Parallel Garbage Collection, a Stop-the-World collector in Java that offers generational-based memory management, compaction, and multithreaded object reallocation. Learn about its evolution, usage, comparison with G1 GC, generations, algorithm, phases, and tuning techniques for optimal performance.

  • Java
  • Garbage Collection
  • ParallelGC
  • Generations
  • Tuning

Uploaded on | 2 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. ParallelGC Intro to ParallelGC

  2. Overview Parallel 1. Generational based (this means the log do not have Young, Terenure, Old) 2. Not region based 3. Stop the world collector - meaning it has STW phases 4. Reallocation of objects is done with compaction 5. Had suffered great changed in JDK 6 (previously only young generation was multithreaded and old generation was single threaded).

  3. Do not confuse UseParallelOldGC vs UseParallelGC Before JDK 6, the parallel part was only in the young generation, and the old would accumulate for a single STW thread to collect it. Then, it was added multithreaded in the parallel using the UseParallelOldGC. Finally, JDK 7 had as default UseParallelOldGC and UseParallelGC, one triggers the other. Conclusion: everything is parallel (both collections).

  4. Usage -XX:+UseParallelGC (no need for JDK 8) Throughput collector - not latency collector (g1gc): Otherwise, pause times can be excessive and tend to increase with the increase of the heap dump.

  5. Comparing with G1 Garbage Collector G1 Garbage Collector: default for JDK 11 latency collector ParallelGC: default for JDK 8 throughput collector

  6. Generations Four types of generations: - - - - Eden Tenure Old Free Young Terenure Old Native memory Metaspace

  7. Parallel Algorithm The diagram to show this algorithm is very simple since it is a STW algorithm and there is no concurrent phase whatsoever: so either the GC threads are running or the App:

  8. Phases - Basically the throughput, given by GCTimeRatio, is the main concern here. This flag sets the ratio of garbage collection time to application time to 1 / (1 + <N>). The default value is 1, meaning 1/20 - The algorithm is pretty simple and basically evolves the object life, the tuning that usually is done is either in the number of threads or the regions setting.

  9. Tuning Parallel GC 1. 2. 3. 4. Set the number of ParallelGCThreads flag default Set the goal for MaxGCPauseMillis: maximum pause time goal in milliseconds Changing the rate of young vs old Adv techniques: -UseAdaptiveSizePolicy (enabled by default; disables the small period of time that it takes to do the calculation for what the heap size should be), -Xmn, dense prefix Consult solution https://access.redhat.com/solutions/2162391

  10. Parallel Logs Using PrintGC PrintGCDateStamps PrintGCDetails Memory: 4k page, physical 15908268k(3945480k free), swap 8388604k(8250108k free) CommandLine flags: -XX:CompressedClassSpaceSize=260046848 -XX:GCLogFileSize=3145728 -XX:InitialHeapSize=1366294528 - XX:MaxHeapSize=1366294528 -XX:MaxMetaspaceSize=268435456 -XX:MetaspaceSize=100663296 -XX:NumberOfGCLogFiles=5 -XX:+PrintFlagsFinal - XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:-TraceClassUnloading -XX:+UseCompressedClassPointers - XX:+UseCompressedOops -XX:+UseGCLogFileRotation -XX:+UseParallelGC ParallelOldGC will come as default 2021-10-11T18:35:10.588-0400: 1.660: [GC (Allocation Failure) [PSYoungGen: 334336K->14818K(389632K)] 334336K->14842K(1280000K), 0.0126052 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] Parallel Scavenger Young Generation cleaning of the young generation in minor GC. 2021-10-11T18:35:18.968-0400: 10.039: [GC (GCLocker Initiated GC) [PSYoungGen: 272751K->8233K(395776K)] 326706K->66329K(1286144K), 0.0086991 secs] [Times: user=0.04 sys=0.00, real=0.01 secs] 2021-10-11T18:35:19.019-0400: 10.090: [GC (Metadata GC Threshold) [PSYoungGen: 32341K->1041K(348160K)] 90438K->62469K(1238528K), 0.0045086 secs] [Times: user=0.03 sys=0.00, real=0.00 secs] that s the metadata threshold that has been changed

  11. Interpreting Parallel Logs Similarly to G1GC, the Parallel Collector will show generation Memory: 4k page, physical 15908268k(3945480k free), swap 8388604k(8250108k free) info about the memory XX:+UseParallelGC ParallelOldGC will come as default 2021-10-11T18:35:10.588-0400: 1.660: [GC (Allocation Failure) [PSYoungGen: 334336K->14818K(389632K)] 334336K->14842K(1280000K), 0.0126052 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] Parallel Scavenger Young Generation cleaning of the young generation in minor GC. [GC (GCLocker Initiated GC) [PSYoungGen: 272751K->8233K(395776K)] 326706K->66329K(1286144K), 0.0086991 secs] [Times: user=0.04 sys=0.00, real=0.01 secs] JNI related cleaning [GC (Metadata GC Threshold) [PSYoungGen: 32341K->1041K(348160K)] 90438K->62469K(1238528K), 0.0045086 secs] [Times: user=0.03 sys=0.00, real=0.00 secs] that s the metadata threshold that has been changed

  12. Container details For container, the Parallel collector can be used, instead of the G1GC collector See details on Java Tuning on OpenShift Be sure to use container aware jdk: 1.8.232

  13. Relevant Solutions https://access.redhat.com/solutions/406903 https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html

More Related Content