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
introduction-to-modern-gc
Search
tomoya yokota
May 26, 2018
Technology
10
3k
introduction-to-modern-gc
Shenandoah GC・ZGC・Epsilon GCをざっくり理解したい!
JJUG CCC 2018 Spring での発表資料です
tomoya yokota
May 26, 2018
Tweet
Share
More Decks by tomoya yokota
See All by tomoya yokota
レガシーSolrの Elasticseach移行 Cybozu Tech Meetup #14
yokotaso
0
350
product-sutainability
yokotaso
0
300
the-art-of-develop-culture-at-cybozu
yokotaso
0
3.2k
Go-To-Java9
yokotaso
0
210
障害にすてるところなし
yokotaso
8
3.9k
Other Decks in Technology
See All in Technology
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
240
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1k
UI State設計とテスト方針
rmakiyama
2
300
podman_update_2024-12
orimanabu
1
260
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
160
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
10個のフィルタをAXI4-Streamでつなげてみた
marsee101
0
160
Qiita埋め込み用スライド
naoki_0531
0
350
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
120
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
335
57k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Scaling GitHub
holman
458
140k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
Optimizing for Happiness
mojombo
376
70k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Designing Experiences People Love
moore
138
23k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Transcript
ͬ͘͟Γ Θ͔ͬͨؾʹͳΔ ϞμϯGC ೖ JJUG CCC 2018 Spring @yokotaso
Agenda • ͜Ε·ͰͷGCͱͳͥ৽GC͕ඞཁͳͷ͔ • Shenandoah GC • ZGC • Epsilon
GC
͜Ε·ͰͷGC
GCͱΞϓϦఀࢭ(STW) Compaction GC Parallel GC young gc old gc GC
= ΞϓϦέʔγϣϯεϨουఀࢭ ϝϞϦ͕ϑϥάϝϯτ͠ͳ͍ CPUෛՙখ͍͞ Stop The world = ΞϓϦέʔγϣϯεϨουͷఀࢭ Mark Compaction GC Noop
GCͱΞϓϦఀࢭ(STW) CMS GC Compaction GC young gc marking sweep GC
old gc initial-mark final-remark young gcΞϓϦέʔγϣϯεϨουఀࢭ major gc΄΅ฒྻ ϝϞϦͷϑϥάϝϯτ͕ܽ Stop The world = ΞϓϦέʔγϣϯεϨουͷఀࢭ Concurrent = ΞϓϦέʔγϣϯεϨουͱฒྻ
GCͱΞϓϦఀࢭ(STW) G1GC Compaction GC young gc Marking old gc initial-mark
final-remark young gcΞϓϦέʔγϣϯεϨουఀࢭ major gcඪఀࢭ࣌ؒΛݩʹGCΛߦ͏ ϝϞϦ͕ϑϥάϝϯτ͠ͳ͍ Stop The world = ΞϓϦέʔγϣϯεϨουͷఀࢭ Compaction GC Concurrent = ΞϓϦέʔγϣϯεϨουͱฒྻ
GCͱΞϓϦఀࢭ(STW) Parallel GC CMS GC G1GC young gc Concurrent mark
Concurrent sweep Mark Concurrent mark old gc Compaction GC Compaction GC Compaction GC Compaction GC Compaction GC Noop
GCͱΞϓϦͷఀࢭ(STW) • ίϯύΫγϣϯGCͰఀࢭ ੈܕGCYoung GCͰఀࢭ ੜଘͷΦϒδΣΫτͷආͰఀࢭ • ίϯύΫγϣϯ͠ͳ͍ͱϝϞϦ͕ ϑϥάϝϯτͯ͠͠·͏
ͳͥ৽GCͳͷ͔
৽͍͠GCͷඞཁੑ • ڊେώʔϓΛ͏ΞϓϦέʔγϣϯͷ಄ ElasticsearchͳͲ • ίϯύΫγϣϯܕGCͷఀࢭΛΊ͍ͨ Young GC / G1GCͷίϯύΫγϣϯ
• ώʔϓྖҬͷେ͖͞ͱGCͰͷఀࢭ͕࣌ؒൺྫ
Shenandoah GC
Shenandoah GC • Redhat͕ࣾ։ൃͨ͠GC • 100GBͱ2GBͷఀࢭ͕࣌ؒมΘΒͳ͍ • 2018/05 όοΫϙʔτ͕ඞཁ
GCͷಛ • ੈܕϝϞϦཧΛ͠ͳ͍ • ϦʔδϣϯܕͷϝϞϦཧ • ฒྻϚʔΩϯάɾฒྻίϯύΫγϣϯ • ΞϓϦέʔγϣϯͱฒྻͰಈ͔͠ͳ͕Β ίϯύΫγϣϯGC͢Δ͠͞ͱʁ
ฒྻίϯύΫγϣϯͷ Pointer x = 1 y = 2 z= 3
Pointer x = 1 y= 2 z= 3 GCεϨου͕Ҡಈத • GCεϨου͕ΦϒδΣΫτͷҠಈதʹ ϦϑΝϨϯεͷॻ͖͕͑ى͖ΔՄೳੑ Ͳ͕ͬͪຊʁ
ΦϒδΣΫτͷϔομ͕ΩϞ Pointer Header ͜ΕΛղܾ͢ΔͨΊʹBrooks pointerΛಋೖ ϙΠϯλ͕ࣗҎ֎ͷϔομΛࢦ͍ͯ͠Δ߹ ͦͷઌͷΦϒδΣΫτΛࢀর͢Δ x = 1
y = 2 z = 3 Pointer Header x = 1 y= 2 z= 3 ຊ ผͷॴʹආ
Brooks pointer Pointer Header x = 1 y = 2
z= 3 Pointer Header x = 1 y= 2 z= 3 ࢀরઌ͕ίϯύΫγϣϯ͞Εͨݹ͍ΦϒδΣΫτͳΒ ϔομʔΛͨͲͬͯɺ৽͍͠ΦϒδΣΫτΛࢀর͢Δ
GC શମΛோΊͯΈΔ Region Region Region Region Root
Initial-Mark Root Region Region Region Region Root͔ΒͨͲΕΔΦϒδΣΫτΛϚʔΫ͢Δ Stop the world
Concurrent-Mark Root Region Region Region Region Initial-MarkͰϚʔΫͨ͠ΦϒδΣΫτΛͨͲͬͯϚʔΫ͢Δ Concurrent Ճ͞Εͨࢀর ❌
আ͞Εͨࢀর
Final-Remark Root Region Region Region Region Concurrent-Markதʹൃੜͨ͠ ࢀরͷมߋөɾΰϛΦϒδΣΫτͷ֬ఆ Stop the
world
Concurrent-Compaction Root Region Region Region Region ίϯύΫγϣϯ͢ΔϦʔδϣϯΛܾఆͯ͠ ΦϒδΣΫτΛୀආ͢Δ ୀආ͢ΔϦʔδϣϯ Concurrent
Concurrent-Compaction Root Region Region Region Region ίϯύΫγϣϯ͢ΔϦʔδϣϯΛܾఆͯ͠ ΦϒδΣΫτΛୀආ͢Δ Concurrent
Concurrent-updateReference Root Region Region Region Region ࢀরઌͷϙΠϯλΛୀආઌʹߋ৽͢Δ Concurrent ৽͍͠ࢀর ආઌʹϙΠϯλߋ৽
Final-updateReference Root Region Region Region Region Concurrent-updateReferenceதʹൃੜͨ͠ߋ৽Λө͢Δ Stop the world
ۭʹͳͬͨʂ
GCશମΛͳ͕ΊͯΈΔ Initial Mark Final Remark Concurrent Mark Concurrent Compaction update
Reference Concurrent update Reference final update Reference Application work Application work Application work ฒྻίϯύΫγϣϯͷ͓͔͛Ͱ ίϯύΫγϣϯ࣌ͷSTWΛͳͭͭ͘͠ ϑϥάϝϯτΛ͙͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨ Stop the world
ZGC
ZGC • OracleͰ։ൃ͞ΕͨGC • TBͷώʔϓͰGCʹΑΔఀࢭ࣌ؒ ୯ௐ૿Ճ͠ͳ͍ • 2018/05ɺόοΫϙʔτ͕ඞཁ • Linux
64bit ͷΈಈ࡞
Shenandoah GCͱࣅ͍ͯΔ • ίϯηϓτ Shenandoah GCͱಉ͡ ੈཧͳ͠ɾϦʔδϣϯܕͷϝϞϦཧ ฒྻίϯύΫγϣϯ • Linux
64 bit OSͰ͔͠ར༻Ͱ͖ͳ͍
ZGCͰಛతͳͷ • ΧϥʔɾϙΠϯλ • Linux ԾϝϞϦͷ׆༻ 64bitͷΞυϨεදݱΛϑϧ׆༻͢Δ • ϑΥϫʔσΟϯάɾςʔϒϧ
ΧϥʔɾϙΠϯλ • ΦϒδΣΫτͷঢ়ଶΛΧϥʔͱͯ͠දݱ • ϚʔΫࡁ 0(marked0) ϚʔΫϑΣʔζʹ͏ • ϚʔΫࡁ 1(marked1)
ޙͰৄ͘͠ • ΦϒδΣΫτආࡁ (remapped)
ΦϒδΣΫτͷΞυϨεදݱ 42 bit ࠷େ4TBͷΞυϨεΛදݱͰ͖Δ 4 1 17 bit ະ༻ ΧϥʔϙΠϯλΛදݱ
1. 64bitͷΞυϨεۭؒશ෦͏ 2. ώʔϓΞυϨεԼҐ42bitΛར༻ 3. 4bitͰΧϥʔϙΠϯλͷ৭Λදݱ
64bitΞυϨεΛ࠷େݶར༻ Heap(4TB) marked0 marked1 remapped 0x0000040000000000 0x0000000000000000 0x0000080000000000 0x00000C0000000000 0x0000100000000000
0x0000140000000000 0x000010001234abcdef 1. ΦϒδΣΫτආࡁΈ 2. 001234abcdefʹ࣮ମ ZGCͰ64bitͷΞυϨεΛ͏.ϝϞϦ͕128TBඞཁ
ڊେϝϞϦͷਖ਼ମԾԽ • ZGCͰ64bitΛͯ͢͏ͷͰ128TBඞཁ • ͦΜͳڊେͳϝϞϦͳ͍ΜͰ͕͢… ͦ͜ͰԾϝϞϦΛͬͯղܾ͢Δ Linuxͷ͍͍ຊ͕࠷ۙͰͨΒ͍͠Ͱ͢Α
GC શମΛோΊͯΈΔ Region Region Region Region Root
Initial-Mark Root Region Region Region Region Root͔ΒͨͲΕΔΦϒδΣΫτΛ ͰϚʔΫ͢Δ Stop the
world
Concurrent-Mark Root Region Region Region Region Initial-MarkͰϚʔΫͨ͠ΦϒδΣΫτΛͨͲͬͯϚʔΫ͢Δ Concurrent Ճ͞Εͨࢀর ❌
আ͞Εͨࢀর
Final-Remark Root Region Region Region Region Concurrent-Markதʹൃੜͨ͠ࢀরͷมߋөͱ ΰϛΦϒδΣΫτͷ֬ఆ Stop the
world
Concurrent-Compaction Root Region Region Region Region ίϯύΫγϣϯ͢ΔϦʔδϣϯΛܾఆ. ΦϒδΣΫτΛආࡁΈͷ ͰϚʔΫͯ͠ɺୀආ͍ͯ͘͠ɻ ୀආ͢ΔϦʔδϣϯ
Concurrent
Concurrent-Compaction Root Region Region Region Region Concurrent ආͨ͠ΦϒδΣΫτ ϑΥϫʔσΟϯάςʔϒϧʹϙΠϯλΛه ϑΥϫʔσΟϯάɾςʔϒϧ
ϑΥϫʔσΟϯάɾςʔϒϧ • Shenandoah GCͩͱΦϒδΣΫτ͝ͱʹ ϔομʔΛ͚ΔɺΦʔόʔϔου͕େ͖͍ • ΧϥʔϙΠϯλͷ͓͔͛ͰΦϒδΣΫτ͕ ݹ͍ɾ৽͍͠ΛஅՄೳ • ϑΥϫʔσΟϯάɾςʔϒϧͰϝϞϦઅ
ࢀরͷߋ৽ʁ
GCશମΛͳ͕ΊͯΈΔ Initial Mark Final Remark Concurrent Mark Concurrent Compaction Application
work Application work
GCશମΛͳ͕ΊͯΈΔ ark Final Remark oncurrent Mark Concurrent Compaction pplication work
Application work Initial Mark Final Remark Concurrent Mark/Remap Concurrent Compaction Application work Application work GC1प GC2प
ࢀরͷߋ৽࣍ͷGCαΠΫϧͰ • ࢀরͷߋ৽࣍ͷConcurrent-MarkதʹΔ • ਖ਼໊ࣜশConcurrent-Mark/Remap • ࢀরΛͨͲΔճΛઅ • ϚʔΩϯά͞ΕͨΦϒδΣΫτ ͍ͭͷGCαΠΫϧͰϚʔΩϯά͞Εͨʁ
Concurrent-Mark/Remap Root Region Region Region Region Concurrent ৽͘͠Ճ͞ΕͨࢀরΧϥʔϙΠϯλͷ ϑϥά͕ҧ͏ͷͰɺ ͰϚʔΫ͠ͳ͓͠
ϑΥϫʔσΟϯάɾςʔϒϧ ࢀর͕Ճ͞ΕͨͷͰ ϚʔΫ͠͠
Concurrent-Mark/Remap Root Region Region Region Region Concurrent ΦϒδΣΫτͷࢀরΛߋ৽ආ. ϦʔδϣϯΛશʹഇغ͢Δ ۭʹͳͬͨʂ
ආ
Epsilon GC
Epsilon GC • ΞϓϦέʔγϣϯεϨουఀࢭ͠ͳ͍ • CPUͷෛՙ΄ͱΜͲͳ͠ • GCͷ࣌ؒݶΓͳ͘0ʹ͍ۙ
ͳͥͳΒ
ͳʹ͠ͳ͍GC
ʋ(ŋωŋ)/ţƄŠŖ
Epsilon GC • JVM։ൃ༻ͷGC • ύϑΥʔϚϯεଌఆ࣌ʹGCͰͷੑೳྼԽΛ ഉআ͢ΔͨΊ • ώʔϓ͕ຒ·Δͱ OutOfMemoryError
• ຊ൪ڥͰΘͳ͍ͰͶ
·ͱΊ • ڊେώʔϓɾଟίΞલఏΞϓϦέʔγϣϯ༻GC ఀࢭ͕࣌ؒͳΒݕ౼ͷՁ͋Γ • Linux 64 bit OSͳΒ ZGC
• ͦΕҎ֎ͳΒ Shenandoah GC • Epsilon GCԿ͠ͳ͍GC