Your SlideShare is downloading. ×
0
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Hotspot gc
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Hotspot gc

1,151

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,151
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
33
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Hotspot GC Tuning Michał Warecki
  • 2. Generational space
  • 3. G1 Heap (Dynamic) Eden Survivor Old Humongous Unused
  • 4. Know your goal ● Different applications require different GC behavior – ● No one-size-fits-all solution regarding GC and performance User aspects: – – ● Throughput Pauses Engineering aspects: – Footprint – Scalability
  • 5. GC Benchmarks ● Hardware – Production like ● ● Data – Production like in volumes and veracity ● ● Why? Phantom bottlenecks Why? Phantom bottlenecks i.e. caches Tests – No micro-benchmarks – Production like tests
  • 6. Tuning for throughput ● Increase heap size – ● Reduce overall need for GC Let objects die in young generation – – GC in old generation is more expensive than in young generation prevent promotion of medium lifetime objects into old generation
  • 7. Let objects die in young generation ● Increase young generation size – ● Only limited by need for old generation size Keep objects in survivor space – Increase survivors space – Raise occupancy threshold – Raise age threshold ● ● ● pro: prevents promotion of medium lifetime objects con: needlessly copies around long lifetime objects Use parallel young GC – increases throughput, if >>2 CPUs available
  • 8. Tuning for minimal pause time ● Use parallel GC (parallel young and parallel compact) – ● Reduces pause time, if >>2 CPUs available Use concurrent GC (CMS) – – ● pro: mostly concurrent con: fragmentation + more expensive young GC Try out "G1" – Designed to limit pause time and frequency
  • 9. Tuning CMS ● Avoid stop-the-world pauses – Reduce duration of full GC – Avoid full GC altogether
  • 10. Prevent fallback to stop-the-world GC ● Increase heap size – ● Start CMS early, i.e. lower occupancy threshold – ● Defers the problems ("night time GC") Reduces throughput because GC runs practically all the time Increase young generation size – Avoids fragmentation in the first place
  • 11. Hotspot GC “packs” ● -XX:+UseSerialGC ● -XX:+UseParallelGC ● -XX:+UseParallelOldGC ● -XX:+UseConcMarkSweepGC ● -XX:+UseG1GC
  • 12. Serial GC (STW) ● -XX:+UseSerialGC – ● Single threaded young and old generation -XX:+UseParallelGC – Single threaded old generation
  • 13. Parallel GC (STW) ● -XX:+UseParallelGC – ● -XX:UseParallelOldGC – ● Parallel young generation Parallel young and old generation -XX:+UseConcMarkSweepGC – Parallel young generation
  • 14. (Mostly) Concurrent GC ● -XX:+UseConcMarkSweepGC – Mostly concurrent old generation – Young gen is still full STW
  • 15. G1 GC ● -XX:UseG1GC – Serial, Parallel and Concurrent
  • 16. Scavenger Phases ● Scavenge ● Reference ● SoftReference ● WeakReference ● FinalReference ● PhantomReference ● JNI Weak Reference ● String Table
  • 17. CMS phases (1/2)
  • 18. CMS phases (2/2) ● Initial mark ● Concurrent mark ● Precleaning ● Remark ● Sweep ● Reset data structures
  • 19. GC Monitoring JVisualVM
  • 20. GC Monitoring Java Mission Control
  • 21. GC Monitoring Logs -verbose:gc -Xloggc:gclogs.txt -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime
  • 22. GC logs ParNew
  • 23. GC logs ParNew
  • 24. GC logs CMS
  • 25. GC logs CMS
  • 26. GC Logs G1 (wow!) 2013-09-29T13:17:21.424+0200: 10.978: [GC pause (young) (to-space overflow), 0.01560900 secs] [Parallel Time: 9.9 ms] [GC Worker Start (ms): 10978.3 10978.4 10978.4 10978.4 10978.5 10978.6 10978.6 10978.6 Avg: 10978.5, Min: 10978.3, Max: 10978.6, Diff: 0.3] [Ext Root Scanning (ms): 2.3 2.0 2.2 2.2 2.0 1.9 1.6 2.4 Avg: 2.1, Min: 1.6, Max: 2.4, Diff: 0.8] [Update RS (ms): 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 Avg: 0.0, Min: 0.0, Max: 0.2, Diff: 0.2] [Processed Buffers : 0 26 0 0 0 5 0 0 Sum: 31, Avg: 3, Min: 0, Max: 26, Diff: 26] [Scan RS (ms): 0.2 0.3 0.0 0.2 0.1 0.3 0.0 0.0 Avg: 0.1, Min: 0.0, Max: 0.3, Diff: 0.2] [Object Copy (ms): 5.9 5.9 7.3 5.9 6.1 7.1 6.6 6.8 Avg: 6.5, Min: 5.9, Max: 7.3, Diff: 1.4] [Termination (ms): 1.2 1.2 0.0 1.2 1.2 0.0 1.2 0.0 Avg: 0.7, Min: 0.0, Max: 1.2, Diff: 1.2] [Termination Attempts : 1 2 1 2 2 1 1 1 Sum: 11, Avg: 1, Min: 1, Max: 2, Diff: 1] [GC Worker End (ms): 10988.0 10988.0 10987.9 10988.0 10988.0 10987.9 10988.0 10988.0 Avg: 10988.0, Min: 10987.9, Max: 10988.0, Diff: 0.1] [GC Worker (ms): 9.6 9.6 9.6 9.5 9.5 9.4 9.4 9.3 Avg: 9.5, Min: 9.3, Max: 9.6, Diff: 0.3] [GC Worker Other (ms): 0.3 0.3 0.4 0.4 0.5 0.5 0.5 0.6 Avg: 0.4, Min: 0.3, Max: 0.6, Diff: 0.3] [Clear CT: 0.7 ms] [Other: 5.0 ms] [Choose CSet: 0.1 ms] [Ref Proc: 0.9 ms] [Ref Enq: 0.0 ms] [Free CSet: 1.2 ms] [Eden: 400M(400M)->0B(377M) Survivors: 0B->23M Heap: 476M(500M)->157M(500M)] [Times: user=0.07 sys=0.02, real=0.01 secs]
  • 27. GC Logs G1 ● Ext Root Scanning ● Update RS (Remembered Set) ● Scan RS ● Object Copy ● Termination ● GC Worker End ● GC Worker ● GC Worker Other ● Clear CT (Card table) ● Other (Choose CSet – Collection Set, Ref Proc, Ref Enq, Free CSet)
  • 28. G1 Remembered Sets Ref: http://www.infoq.com/articles/tuning-tips-G1-GC
  • 29. Useful options -Xmn -Xmx -Xms -XX:SurvivorRatio=X -XX:MaxTenuringThreshold=XX -XX:+UseConcMarkSweepGC -XX:+CMSScavengeBeforeRemark -XX:+CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=XX -XX:+UseCMSInitiatingOccupancyOnly -XX:ParallelGCThreads=X -XX:+UseGCTaskAffinity -XX:+BindGCTaskThreadsToCPUs -XX:ParGCCardsPerStrideChunk=XXXXX -XX:+UseCondCardMark
  • 30. Thanks! Questions?

×