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
190
gh_extensionsによる快適なOSS生活.pdf
sivchari
0
7
Visualization Go scheduler by gosched-simulator
sivchari
1
350
protoc pluginのはじめかた
sivchari
0
22
What's context package
sivchari
0
18
Dive into arena package ~ Go 1.20 release party ~
sivchari
0
41
GopherCon 2023 recap
sivchari
0
21
Go 1.22 range over func/range over int
sivchari
0
32
Deep dive into runtime features provided by Go1.22
sivchari
0
20
Featured
See All Featured
Building Your Own Lightsaber
phodgson
104
6.2k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
10
1.3k
KATA
mclloyd
29
14k
Site-Speed That Sticks
csswizardry
4
410
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
520
4 Signs Your Business is Dying
shpigford
182
22k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
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 1HPS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αϯϓϧίʔυ
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~