Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JVM GCs and why should I care?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Maciej Biłas
June 28, 2013
Technology
78
0
Share
JVM GCs and why should I care?
Very brief introduction into JVM GC tuning given at a SoftwareMill tech talk.
Maciej Biłas
June 28, 2013
More Decks by Maciej Biłas
See All by Maciej Biłas
akka-cluster-etcd
maciejb
0
270
Testing with Docker
maciejb
1
110
ArchieML
maciejb
0
150
I code for Warsaw
maciejb
0
210
Warsaw JUG: Listen to the sounds of your application
maciejb
0
160
Poznań JUG: Listen to the sounds of your application
maciejb
0
84
Other Decks in Technology
See All in Technology
AI駆動開発でなんでもハンズオン環境をつくってみた
yoshimi0227
0
200
サイバーセキュリティ概論 / Introduction to Cybersecurity
ks91
PRO
0
120
インフラが苦手でも大丈夫! 紙芝居 Kubernetes -WWGT 10周年編-
aoi1
1
330
APIテストとは?
nagix
0
170
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.8k
Generative UI × A2UI で AI エージェントを作った話 AI-DLC も使ってみた!
kmiya84377
1
310
TypeScript Compiler APIとPHP-Parserを活用し、TypeScriptとPHPで型を共有する
shuta13
0
320
ポスター発表&デモと総括 / Poster Presentations & Demonstrations and Summary
ks91
PRO
0
190
大学生が本気でDatabricksを活用してDiscordサークルをデータ駆動させてみた
phantomjuju
1
330
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
200
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Mind Mapping
helmedeiros
PRO
1
230
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.6k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
280
New Earth Scene 8
popppiees
3
2.3k
Being A Developer After 40
akosma
91
590k
GitHub's CSS Performance
jonrohan
1033
470k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
590
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Transcript
JVM GCs and why should I care? Maciej Biłas <
[email protected]
>
You should not unless you have to
How do I tell I have to? -verbose:gc -Xloggc:<filename> -XX:+PrintGCDetails
-XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime
Yes, now you have to time since start: [Full] GC
heap_taken_before_GC -> heap_taken_after_GC (total heap size) pause in seconds 29422.361: [Full GC 1704272K->1175099K(1781760K), 5.2196310 secs] 29427.588: [GC 1176939K(1781760K), 0.0135230 secs] 29430.034: [Full GC 1651801K->1239586K(1781760K), 5.3722150 secs] 29435.591: [Full GC 1411504K->1196906K(1781760K), 5.3212200 secs]
What now? Add more memory to the heap before doing
any GC tuning.
Pro tips • Have a realistic stress test • Diagnose
if the problem is GC-related • Define your performance goals
What to optimize? • Throughput • Latency • Memory
Available collectors • Serial • Parallel • CMS (+ parallel
new) • G1 • experimental in late Java 6, available in Java 7
The heap
Perm gen • Perm gen does not count to heap
size • Perm gen is gone since Java 8
JVM defaults if CPUs >= 2 && memory >= 2GiB
server else client
Client and server classes Machine Heap size GC Client ???
Serial Server Initial: memory / 64 Max: MIN(memory / 4, 1GiB) Parallel Source: http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#par_gc.ergonomics.default_size
JSW case -server -Xms5000m -Xmx5000m -XX:NewRatio=1 -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC
-XX:+UseCompressedOops -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -verbose:gc
JSW after tuning 2022.201: [GC 2022.201: [ParNew: 2176832K- >139349K(2304000K), 0.1241120
secs] 2311896K- >274413K(4864000K) icms_dc=0 , 0.1243120 secs] [Times: user=0.48 sys=0.00, real=0.13 secs] 2746.297: [GC 2746.298: [ParNew: 2187349K- >122293K(2304000K), 0.2227440 secs] 2322413K- >327073K(4864000K) icms_dc=0 , 0.2229290 secs] [Times: user=0.67 sys=0.08, real=0.23 secs] 3528.443: [GC 3528.443: [ParNew: 2170293K- >57977K(2304000K), 0.0544880 secs] 2375073K- >278050K(4864000K) icms_dc=0 , 0.0546750 secs] [Times: user=0.18 sys=0.02, real=0.06 secs]
You can also try -XX:MaxGCPauseMillis
Not covered here • Most GC tuning flags • Go
check them yourselves • Safe points • Other GC implementations • the pauseless one from Azul especially
Resources • JVM 6.0 Tuning http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html • List of JVM
options http://www.oracle.com/technetwork/java/javase/tech/vmoptions- jsp-140102.html • Sizing TLABs https://blogs.oracle.com/daviddetlefs/entry/tlab_sizing_an_annoying_little • Server class machine detection http://docs.oracle.com/javase/6/docs/technotes/guides/vm/server- class.html • Java Garbage Collection Distilled http://www.infoq.com/articles/Java_Garbage_Collection_Distilled