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
Storage Browser for Amazon S3
miu_crescent
1
180
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
220
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
460
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
なぜCodeceptJSを選んだか
goataka
0
160
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
190
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
14
12k
C++26 エラー性動作
faithandbrave
2
740
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
240
UI State設計とテスト方針
rmakiyama
2
600
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
850
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Why Our Code Smells
bkeepers
PRO
335
57k
Mobile First: as difficult as doing things right
swwweet
222
9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Code Reviewing Like a Champion
maltzj
520
39k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
The Cult of Friendly URLs
andyhume
78
6.1k
The Pragmatic Product Professional
lauravandoore
32
6.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