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
360
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
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.5k
Amazon Route 53, 待ちに待った TLSAレコードのサポート開始
kenichinakamura
0
170
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.4k
なぜfreeeはハブ・アンド・スポーク型の データメッシュアーキテクチャにチャレンジするのか?
shinichiro_joya
2
490
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
7
6.5k
re:Invent2024 KeynoteのAmazon Q Developer考察
yusukeshimizu
1
150
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
1
16k
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
comilioとCloudflare、そして未来へと向けて
oliver_diary
6
450
Accessibility Inspectorを活用した アプリのアクセシビリティ向上方法
hinakko
0
180
タイミーのデータ活用を支えるdbt Cloud導入とこれから
ttccddtoki
1
150
Featured
See All Featured
Side Projects
sachag
452
42k
A better future with KSS
kneath
238
17k
For a Future-Friendly Web
brad_frost
176
9.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Speed Design
sergeychernyshev
25
740
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
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