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
2.9k
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
340
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
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
280
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
290
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
130
AIチャットボット開発への生成AI活用
ryomrt
0
170
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
120
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
490
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
1
2.3k
Featured
See All Featured
Unsuck your backbone
ammeep
668
57k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Code Reviewing Like a Champion
maltzj
520
39k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Rails Girls Zürich Keynote
gr2m
94
13k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Building Applications with DynamoDB
mza
90
6.1k
Embracing the Ebb and Flow
colly
84
4.5k
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