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 GOCACHEPROG ?
sivchari
1
200
gh_extensionsによる快適なOSS生活.pdf
sivchari
0
8
Visualization Go scheduler by gosched-simulator
sivchari
1
360
protoc pluginのはじめかた
sivchari
0
23
What's context package
sivchari
0
19
Dive into arena package ~ Go 1.20 release party ~
sivchari
0
42
GopherCon 2023 recap
sivchari
0
23
Go 1.22 range over func/range over int
sivchari
0
34
Deep dive into runtime features provided by Go1.22
sivchari
0
21
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
69
10k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
13
1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
A Philosophy of Restraint
colly
203
16k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
260
Become a Pro
speakerdeck
PRO
26
5.2k
Designing for humans not robots
tammielis
250
25k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
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Λ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࣋͢ΔHMPCBMRVFVF sched
~goroutineͷϥΠϑλΠϜ~
αϯϓϧίʔυ
newproc . 1 ( SVOR $SFBUFHPSPVUJOF
newproc1 ( . 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~