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
The Rise of LLMOps
asei
7
1.7k
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
TypeScript、上達の瞬間
sadnessojisan
46
13k
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
SSMRunbook作成の勘所_20241120
koichiotomo
3
160
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
300
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
430
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
130
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
150
Featured
See All Featured
Side Projects
sachag
452
42k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Happy Clients
brianwarren
98
6.7k
Building Adaptive Systems
keathley
38
2.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Gamification - CAS2011
davidbonilla
80
5k
Designing Experiences People Love
moore
138
23k
A Tale of Four Properties
chriscoyier
156
23k
Producing Creativity
orderedlist
PRO
341
39k
Making Projects Easy
brettharned
115
5.9k
Being A Developer After 40
akosma
87
590k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
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