Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JDD2015: -XX:+UseG1GC - Jakub Kubryński

139 views

Published on

-XX:+USEG1GC

Since JDK 9 G1 will be default GC algorithm. Meanwhile, the level of its usage or just knowledge of the principles is much lower when compared to the number of myths and urban legends. We should know, that G1 introduces revolutionizing approach to memory management in the JVM by changing both the current structure of the heap and way of running major and minor collections. But unfortunately there are still some "childhood diseases" we should be aware of.
During the presentation, I will describe the algorithm, its characteristics and the real possibility of usage on a daily basis. We'll also discus some tricks allowing for stress-free deployment and optimization.

Published in: Software
  • Be the first to comment

  • Be the first to like this

JDD2015: -XX:+UseG1GC - Jakub Kubryński

  1. 1. @jkubrynskijk@devskiller.com -XX:+UseG1GC Jakub Kubryński @jkubrynski
  2. 2. @jkubrynskijk@devskiller.com Who are we? - Me - $ since 2004 - Co-Founder of DevSKiller.com + Codearte.io - JVM passionate - Trainer @ Bottega - You - Java developers? - GC logs analysts? - JVM tuners?
  3. 3. @jkubrynskijk@devskiller.com Why all this mess? Because applications need memory... … and memory is limited Developers are too lazy to manage memory manually... … and Garbage Collector has a limited performance and a need to stop the world
  4. 4. @jkubrynskijk@devskiller.com Vector algorithm mark_gc_roots() for (each_root_object) { mark_all_referenced_objects() } for (each_object_in_memory) { if (is_marked_as_reacheable) { unmark_the_object() } else { remove_object_and_reclaim_memory() } }
  5. 5. @jkubrynskijk@devskiller.com Generational hypothesis
  6. 6. @jkubrynskijk@devskiller.com Card table
  7. 7. @jkubrynskijk@devskiller.com Concurrency
  8. 8. @jkubrynskijk@devskiller.com Freeing memory
  9. 9. @jkubrynskijk@devskiller.com Copying algorithm
  10. 10. @jkubrynskijk@devskiller.com Let's split the heap
  11. 11. @jkubrynskijk@devskiller.com G1 in action
  12. 12. @jkubrynskijk@devskiller.com G1 in action
  13. 13. @jkubrynskijk@devskiller.com G1 in action
  14. 14. @jkubrynskijk@devskiller.com G1 in action
  15. 15. @jkubrynskijk@devskiller.com G1 in action
  16. 16. @jkubrynskijk@devskiller.com Remembered Set (RSet)
  17. 17. @jkubrynskijk@devskiller.com Important terms Collection Set (CSet) Root Regions
  18. 18. @jkubrynskijk@devskiller.com Collections in G1 Young collection Background concurrent cycle Mixed collection Full GC
  19. 19. @jkubrynskijk@devskiller.com Young GC Triggered after filling all Eden regions Parallel Stop-The-World
  20. 20. @jkubrynskijk@devskiller.com Concurrent cycle Piggybacked on Young GC, which works as a initial- mark Looks for easiest regions to clean (min live objects) - concurrent-root-region-scan - concurrent-mark - concurrent-cleanup
  21. 21. @jkubrynskijk@devskiller.com Mixed GC Regions marked in the previous step are cleaned during mixed collections Young generation + part of old Processes - min => marked regions count / G1MixedGCCountTarget - max => 10% of all regions
  22. 22. @jkubrynskijk@devskiller.com Full GC Veeery slow serial collector Cleans everything
  23. 23. @jkubrynskijk@devskiller.com G1 Tuning -XX:MaxGCPauseMillis=250
  24. 24. @jkubrynskijk@devskiller.com G1 Tuning – the dark side G1ConcMarkForceOverflow G1ConcMarkStepDurationMillis G1ConcRSHotCardLimit G1ConcRSLogCacheSize G1ConcRefinementGreenZone G1ConcRefinementRedZone G1ConcRefinementServiceIntervalMillis G1ConcRefinementThreads G1ConcRefinementThresholdStep G1ConcRefinementYellowZone G1ConcRegionFreeingVerbose G1ConfidencePercent G1DummyRegionsPerGC G1EvacuationFailureALot G1EvacuationFailureALotCount G1EvacuationFailureALotDuringConcMark G1EvacuationFailureALotDuringInitialMark G1EvacuationFailureALotDuringMixedGC G1EvacuationFailureALotDuringYoungGC G1EvacuationFailureALotInterval G1ExitOnExpansionFailure G1FailOnFPError G1HRRSFlushLogBuffersOnVerify G1HRRSUseSparseTable G1HeapRegionSize G1HeapWastePercent G1MarkingOverheadPercent G1MarkingVerboseLevel G1MaxVerifyFailures G1MixedGCCountTarget G1PrintHeapRegions G1PrintRegionLivenessInfo G1RSBarrierRegionFilter G1RSScrubVerbose G1RSetRegionEntries G1RSetRegionEntriesBase G1RSetScanBlockSize G1RSetSparseRegionEntries G1RSetSparseRegionEntriesBase G1RSetUpdatingPauseTimePercent G1RecordHRRSEvents G1RecordHRRSOops G1RefProcDrainInterval G1ReservePercent G1SATBBufferEnqueueingThresholdPercent G1SATBBufferSize G1SATBProcessCompletedThreshold G1ScrubRemSets G1SecondaryFreeListAppendLength G1StressConcRegionFreeing G1StressConcRegionFreeingDelayMillis G1SummarizeConcMark G1SummarizeRSetStats G1SummarizeRSetStatsPeriod G1TraceConcRefinement G1TraceHeapRegionRememberedSet G1TraceMarkStackOverflow G1UpdateBufferSize G1UseAdaptiveConcRefinement G1VerifyBitmaps G1VerifyCTCleanup G1VerifyHeapRegionCodeRoots G1VerifyRSetsDuringFullGC G1YoungSurvRateNumRegionsSummary G1YoungSurvRateVerbose PrintCFG1
  25. 25. @jkubrynskijk@devskiller.com Good practices -XX:InitiatingHeapOccupancyPercent=45 -XX:ConcGCThreads=(processors+3)/4 -XX:G1ReservePercent=10 -XX:+ParallelRefProcEnabled
  26. 26. @jkubrynskijk@devskiller.com Humongous Humongous > ½ G1RegionSize G1 Humongous Allocation can cause Major GC Humongous is evil Eliminate them by extending region size
  27. 27. @jkubrynskijk@devskiller.com What else should we look for? Concurrent mode failure Promotion failure Evacuation failure
  28. 28. @jkubrynskijk@devskiller.com Logs [GC pause (G1 Evacuation Pause) (young), 0.2611788 secs] [Parallel Time: 257.3 ms, GC Workers: 8] [GC Worker Start (ms): Min: 32183.4, Avg: 32185.5, Max: 32196.3, Diff: 12.9] [Ext Root Scanning (ms): Min: 0.0, Avg: 0.4, Max: 0.8, Diff: 0.8, Sum: 2.8] [Update RS (ms): Min: 7.2, Avg: 18.4, Max: 27.2, Diff: 20.0, Sum: 147.3] [Processed Buffers: Min: 5, Avg: 10.2, Max: 17, Diff: 12, Sum: 82] [Scan RS (ms): Min: 79.1, Avg: 85.6, Max: 87.3, Diff: 8.1, Sum: 684.9] [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0] [Object Copy (ms): Min: 148.3, Avg: 148.9, Max: 150.8, Diff: 2.5, Sum: 1190.9] [Termination (ms): Min: 0.0, Avg: 1.8, Max: 2.1, Diff: 2.1, Sum: 14.7] [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1] [GC Worker Total (ms): Min: 244.3, Avg: 255.1, Max: 257.2, Diff: 12.9, Sum: 2040.8] [GC Worker End (ms): Min: 32440.6, Avg: 32440.6, Max: 32440.6, Diff: 0.0] [Code Root Fixup: 0.0 ms] [Code Root Purge: 0.0 ms] [Clear CT: 0.1 ms] [Other: 3.8 ms] [Choose CSet: 0.0 ms] [Ref Proc: 0.2 ms] [Ref Enq: 0.0 ms] [Redirty Cards: 0.6 ms] [Humongous Reclaim: 0.0 ms] [Free CSet: 2.2 ms] [Eden: 172.0M(172.0M)->0.0B(173.0M) Survivors: 25.0M->25.0M Heap: 1912.0M(3940.0M)->1870.0M(3972.0M)] [Times: user=2.00 sys=0.02, real=0.26 secs]
  29. 29. @jkubrynskijk@devskiller.com Tools GCViewer JVisualVM Mission Control
  30. 30. @jkubrynskijk@devskiller.com Anything else? Parallel ConcurrentMarkSweep Shenandoah
  31. 31. @jkubrynskijk@devskiller.com Will stay default in JDK 9? Kirk Pepperdine: Using G1 is known to corrupt Lucene indexes Charlie Hunt: Does the term "known" imply past tense? ;-) You know I'm just having a little fun with you, right? Kirk Pepperdine: Dude, seriously.. Stefan Johansson: A short heads up. The change to make G1 the default garbage collector has now made its way to jdk9/dev and should soon be part of a JDK 9 early access build.
  32. 32. @jkubrynskijk@devskiller.com Questions
  33. 33. @jkubrynskijk@devskiller.com Thanks! @_tessr from #gophercon

×