Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Understanding Memory Management of JavaVM in 15 minutes
Shinji Tanaka
April 07, 2014
Technology
13
2.2k
Understanding Memory Management of JavaVM in 15 minutes
Shinji Tanaka
April 07, 2014
Tweet
Share
More Decks by Shinji Tanaka
See All by Shinji Tanaka
Mackerel loves Machine Learnings
stanaka
0
2.5k
How to Contribute Go
stanaka
4
17k
Introduction to Mackerel
stanaka
0
850
Upcoming features in 2016, Mackerel
stanaka
0
3k
Mackerel's first year and onward
stanaka
0
2.5k
Mackerel's first year and onward (in English)
stanaka
0
300
Blue-Green Deployment with ECS and monitoring
stanaka
0
500
Mackerel Meetup #4 (in Eng)
stanaka
0
380
Mackerel Meetup #4
stanaka
0
2.6k
Other Decks in Technology
See All in Technology
Red Hat Enterprise Linux 9のリリースノートを読む前に知りたい最近のキーワードをまとめて復習
moriwaka
0
370
殺虫剤のパラドックスの真実 / The Truth of The Pesticide Paradox
kzsuzuki
1
180
SBOMを利用したソフトウェアサプライチェーンの保護
masahiro331
1
200
20220803投資先CXO候補者向け 会社紹介資料_合同会社BLUEPRINT
hik
0
550
Amazon SageMakerが存在しない世界線のAWS上で実現する機械学習基盤
sadynitro
0
120
DeFiChain Tech Talk - DFI Uniswap Staking, DeFi Options & DeFi Meta Chain
uzyn
0
120
ソフトウェアアーキテクチャの基礎: Software Architecture in a Nutshell
snoozer05
31
9.1k
ここが好きだよAWS管理ポリシー_devio2022/i_am_iam_lover
yukihirochiba
0
3.2k
hey BOOK
heyinc
26
290k
疎ベクトル検索と密ベクトル検索: 第68回 Machine Learning 15minutes! Broadcast
keyakkie
1
250
今 SLI/SLO の監視をするなら Sloth が良さそうという話
shotakitazawa
1
290
ぼくらが選んだ次のMySQL 8.0 / MySQL80 Which We Choose
line_developers
PRO
7
3.1k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
260
25k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
498
130k
The MySQL Ecosystem @ GitHub 2015
samlambert
239
11k
The Language of Interfaces
destraynor
148
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
638
52k
Six Lessons from altMBA
skipperchong
14
1.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
7
1.1k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
6k
For a Future-Friendly Web
brad_frost
166
7.5k
Principles of Awesome APIs and How to Build Them.
keavy
113
15k
Producing Creativity
orderedlist
PRO
334
37k
How To Stay Up To Date on Web Technology
chriscoyier
780
250k
Transcript
Understanding Memory Management of JavaVM in 15 minutes @stanaka /
id:stanaka JVM Operation Casual Talks at 2014/4/7
Shinji TANAKA CTO at Hatena Co., Ltd. ࠷ۙͷ׆ಈ: Immutable Infrastructure
@stanaka / id:stanaka We’re Hiring at both KYOTO and TOKYO!
Java Virtual Machine ʮͯͳʯͰಈ͍͍ͯΔ(͍ͨ)JavaVM Hadoop Solr Elasticsearch Scala ← new!
powered by Scala https://mackerel.io/
JVMͷࠔΓͲ͜Ζ ࡉ͔ͳνϡʔχϯά͕Ͱ͖Δ ىಈ͕͍ σϑΥϧτ͕͍͚ͯͳ͍ ωοτ্ʹݹ͍ใ͕ଟ͍
JVMͷࠔΓͲ͜Ζ ࡉ͔ͳνϡʔχϯά͕Ͱ͖Δ ىಈ͕͍ σϑΥϧτ͕͍͚ͯͳ͍ ωοτ্ʹݹ͍ใ͕ଟ͍ G1HeapRegionSizeͬͯͳʹ?
JVMͷࠔΓͲ͜Ζ ࡉ͔ͳνϡʔχϯά͕Ͱ͖Δ ىಈ͕͍ σϑΥϧτ͕͍͚ͯͳ͍ ωοτ্ʹݹ͍ใ͕ଟ͍ ͍͜ͳ͢ʹɺͪΌΜͱ͕ͨࣝ͠ඞཁ!! G1HeapRegionSizeͬͯͳʹ?
Memory Model in JavaVM Stack ← ελοΫྖҬ εϨου͝ͱʹ͋Δ Non Heap
← JavaVM෦Ͱ͏ྖҬ ίʔυΩϟογϡ (JIT݁ՌͳͲ) Permanent Generation (Java8͔Βআ) Heap ← ΞϓϦέʔγϣϯ͕͏ྖҬ GCର
Heap Young Generation Eden Space Survivor Space (ෳ͋Δ) Old /
Tenured Generation
Garbage Collection Algorithms Mark & Sweep Mark & Compaction Generational
GC (JDK 1.2, 1998) Parallel GC Incremental GC (-Xincgc, Java8Ͱඇਪ) Concurrent Mark-Sweep GC, CMS (JDK 1.4.1 2002) Garbage-First GC, G1 GC (JDK 1.6u14 2009)
Minor-GC from Memory Management in the Java HotSpot Virtual Machine
[Whitepaper2006]
Minor-GC from Memory Management in the Java HotSpot Virtual Machine
[Whitepaper2006]
Parallel Collector from Memory Management in the Java HotSpot Virtual
Machine [Whitepaper2006]
Concurrent GC (CMS) from Memory Management in the Java HotSpot
Virtual Machine [Whitepaper2006]
Pros/Cons of CMS Pros Concurrent! Stop-the-World͕͔͍࣌ؒ Cons Old Gen͕flagmentԽ(compaction͞Εͳ͍)͠ Old
GenͰͷϝϞϦ֬อ͕͘ͳΔ
CMS / G1 from The Garbage-First Garbage Collector [JavaOne2008]
CMS vs G1 ͞ΕͨYoungྖҬΛ࣋ͨͳ͍ (G1) Heap͕ϦʔδϣϯͰׂ͞ΕΔ ΦϒδΣΫτஔͷ࠷దԽ͕͞ΕΔ(G1) SparseͳϦʔδϣϯ࠶ஔ͞ΕCompaction͞ΕΔ Snapshot-at-the-beginingʹΑΔMarking(G1) CMSͰDirty-card
GC Benchmark Parallel CMS G1 Total GC pauses 20,930ms 18,870ms
62,000ms Max GC pause 721ms 64ms 50ms JIRA benchmark test for 30 minutes with -Xms256m -Xmx768m -XX:MaxPermSize=256m https://plumbr.eu/blog/g1-vs-cms-vs-parallel-gc Tuning͢ΔͱG1ͷ΄͏͕CPUෛՙ ؚΊͯྑ͍ͱ͍͏݁Ռ͋Δ [JavaOne2013]
ͲͷGCΛ͏͖? ϫʔΫϩʔυͱαʔόʔεϖοΫ࣍ୈ ώʔϓαΠζ (ඦMBʙेGBʙTB) ΦϒδΣΫτੜɺαΠζɺण໋ͷ CPUޮͱϨΠςϯγͱνϡʔχϯάͷखؒ τϨʔυΦϑ
Reference Memory Management in the Java HotSpot Virtual Machine ˑ
http://www.oracle.com/technetwork/java/javase/memorymanagement-whitepaper-150215.pdf [Whitepaper2006] A Generational Mostly-concurrent Garbage Collector https://www.cs.purdue.edu/homes/hosking/ismm2000/papers/printezis.pdf [ISMM2000] The Garbage-First Garbage Collector http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.63.6386&rep=rep1&type=pdf [ISMM2004] ˑ http://www.oracle.com/technetwork/server-storage/ts-5419-159484.pdf [JavaOne 2008] Garbage-First Garbage Collector: Migration to, Expectations and Advanced Tuning. ˑ http://www.slideshare.net/MonicaBeckwith/garbage-first-garbage-collector-g1-gc-migration-to- expectations-and-advanced-tuning [JavaOne2013] Java Virtual Machine Technology http://docs.oracle.com/javase/8/docs/technotes/guides/vm/ International Symposium on Memory Management (ISMM) http://www.sigplan.org/conferences/ismm/main