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
goroutineの仕組みについて
Search
sivchari
November 13, 2021
0
1.4k
goroutineの仕組みについて
Go Conference 2021 Autumnで発表した資料です
sivchari
November 13, 2021
Tweet
Share
More Decks by sivchari
See All by sivchari
What's context package
sivchari
0
14
Dive into arena package ~ Go 1.20 release party ~
sivchari
0
27
GopherCon 2023 recap
sivchari
0
15
Go 1.22 range over func/range over int
sivchari
0
18
Deep dive into runtime features provided by Go1.22
sivchari
0
15
Go 1.22で追加予定 だった zeroの紹介 Go Conference mini
sivchari
0
280
Dive into testing package ~ Part of Fuzzing Test ~
sivchari
1
230
database/sqlの仕組みについて
sivchari
0
150
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Side Projects
sachag
452
42k
The Cult of Friendly URLs
andyhume
78
6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Designing for humans not robots
tammielis
250
25k
It's Worth the Effort
3n
183
27k
GitHub's CSS Performance
jonrohan
1030
460k
A better future with KSS
kneath
238
17k
4 Signs Your Business is Dying
shpigford
180
21k
The Language of Interfaces
destraynor
154
24k
Designing Experiences People Love
moore
138
23k
Transcript
goroutineͷΈʹ͍ͭͯ ~Go Conference 2021 Autumn~
w 5BLVNB4IJCVZB!TJWDIBSJ w ଔ$ZCFS"HFOU ༧ఆ w όοΫΤϯυΤϯδχΞ w MJOUFS
044͕͖ ࣗݾհ
w (PͷSVOUJNFΛࢧ͑Δཁૉ w HPSPVUJOFͷϥΠϑλΠϜ w HPSPVUJOFͷεέδϡʔϦϯά ͢͜ͱ
~Let's Go~
~GoͷruntimeΛࢧ͑Δཁૉ~
w (HPSPVUJOF w .ϚγϯεϨου w 1HPSPVUJOFΛ࣮ߦ͢ΔϦιʔε w TDIFEάϩʔόϧͰϢχʔ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. 1 ( SVOR
newproc ( . 1 ( SVOR
runqput ( . 1 ( SVOR (
runqputslow TDIFE . 1 ( SVOR (
globruqputbatch TDIFE . 1 ( SVOR ( (
~goroutineͷεέδϡʔϦϯά~
schedule TDIFE . 1 ( SVOR (
globrunqget TDIFE ( . 1 ( SVOR (
schedule . 1 ( SVOR (
runqget ( . 1 ( SVOR (
schedule . 1 ( SVOR
fi ndrunnable ( *0 ❌ @(XBJUJOH@(SVOOBCMF ( . 1
( SVOR
1 . ( SVOR 1 . ( SVOR (
( ( ( ( ( fi ndrunnable
stealWork/runqsteal 1 . ( SVOR 1 ( SVOR (
( ( ( ( ( ( ( ( .
execute ( . 1 ( SVOR
goexit ( . 1 ( SVOR
goexit1 ( . 1 ( SVOR
mcall ( . 1 ( SVOR
UPHGSFF goexit0 ( . 1 ( SVOR
αϯϓϧίʔυ IUUQTQMBZHPMBOHPSHQX81SL$YO)G
w (PಠࣗͷεέδϡʔϥʔͰHPSPVUJOFΛ੍ޚ͍ͯ͠Δ w ֤1͕SVORΛ࣋ͭ͜ͱͰϓϩάϥϜͷޮ͕ߴ·Δ w ෳࡶͳ࣮ͷ͓͔͛Ͱ؆୯ʹฒߦॲཧΛ࣮Ͱ͖Δ ·ͱΊ
~Tank you for watching~