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
Maciej Biłas
June 28, 2013
Technology
0
67
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
Tweet
Share
More Decks by Maciej Biłas
See All by Maciej Biłas
akka-cluster-etcd
maciejb
0
250
Testing with Docker
maciejb
1
100
ArchieML
maciejb
0
140
I code for Warsaw
maciejb
0
200
Warsaw JUG: Listen to the sounds of your application
maciejb
0
150
Poznań JUG: Listen to the sounds of your application
maciejb
0
78
Other Decks in Technology
See All in Technology
KiCadでPad on Viaの基板作ってみた
iotengineer22
0
300
Enhancing SaaS Product Reliability and Release Velocity through Optimized Testing Approach
ropqa
1
230
さくらのIaaS基盤のモニタリングとOpenTelemetry/OSC Hokkaido 2025
fujiwara3
3
440
Operating Operator
shhnjk
1
580
PO初心者が考えた ”POらしさ”
nb_rady
0
210
OSSのSNSツール「Misskey」をさわってみよう(右下ワイプで私のOSCの20年を振り返ります) / 20250705-osc2025-do
akkiesoft
0
160
ネットワーク保護はどう変わるのか?re:Inforce 2025最新アップデート解説
tokushun
0
200
MobileActOsaka_250704.pdf
akaitadaaki
0
120
いつの間にか入れ替わってる!?新しいAWS Security Hubとは?
cmusudakeisuke
0
120
LangChain Interrupt & LangChain Ambassadors meetingレポート
os1ma
2
310
20250707-AI活用の個人差を埋めるチームづくり
shnjtk
4
3.8k
React開発にStorybookとCopilotを導入して、爆速でUIを編集・確認する方法
yu_kod
1
270
Featured
See All Featured
Docker and Python
trallard
44
3.5k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Become a Pro
speakerdeck
PRO
29
5.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
Embracing the Ebb and Flow
colly
86
4.7k
How GitHub (no longer) Works
holman
314
140k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
740
Bash Introduction
62gerente
613
210k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
YesSQL, Process and Tooling at Scale
rocio
173
14k
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