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
Go Scheduler
Search
Cyril Lashkevich
July 21, 2017
Technology
2
610
Go Scheduler
GoWayFest 2017
Cyril Lashkevich
July 21, 2017
Tweet
Share
More Decks by Cyril Lashkevich
See All by Cyril Lashkevich
Bitcode in Swift
notorca
0
51
Mobile Optimized 2014
notorca
1
260
Fun with blocks in ObjC
notorca
1
92
CocoaHeads in Grodno, Lighting
notorca
0
81
Dictionary in Python
notorca
0
120
Foundation data structures
notorca
0
140
iOS memory management
notorca
0
90
NSProxy, multithreading, messaging
notorca
1
98
Python impergections
notorca
0
81
Other Decks in Technology
See All in Technology
Flutterにしてよかった?出前館アプリを2年運用して気づいたことを全部話します
demaecan
0
130
us-east-1 の障害が 起きると なぜ ソワソワするのか
miu_crescent
PRO
3
880
Post-AIコーディング時代のエンジニア生存戦略
shinoyu
0
280
嗚呼、当時の本番環境の状態で AI Agentを再評価したいなぁ...
po3rin
0
420
Claude Code 10連ガチャ
uhyo
3
680
旧から新へ: 大規模ウェブクローラの Perl から Go への移行 / YAPC::Fukuoka 2025
motemen
3
880
ユーザーストーリー x AI / User Stories x AI
oomatomo
0
190
「データ無い! 腹立つ! 推論する!」から 「データ無い! 腹立つ! データを作る」へ チームでデータを作り、育てられるようにするまで / How can we create, use, and maintain data ourselves?
moznion
7
4.2k
[mercari GEARS 2025] Building Foundation for Mercari’s Global Expansion
mercari
PRO
1
120
Quarkusで作るInteractive Stream Application
joker1007
0
140
AIを前提に、業務を”再構築”せよ IVRyの9ヶ月にわたる挑戦と未来の働き方 (BTCONJP2025)
yueda256
1
670
Introducing RFC9111 / YAPC::Fukuoka 2025
k1low
1
240
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
9.2k
The World Runs on Bad Software
bkeepers
PRO
72
12k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Rails Girls Zürich Keynote
gr2m
95
14k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
Facilitating Awesome Meetings
lara
57
6.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Why Our Code Smells
bkeepers
PRO
340
57k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
Building Applications with DynamoDB
mza
96
6.8k
Automating Front-end Workflow
addyosmani
1371
200k
Transcript
Go Scheduler Cyril Lashkevich GoWayFest 2017
Планировщик главное отличие go от современных mainstream языков В остальном
это Pascal c GC
func main() { var x int threads := runtime.GOMAXPROCS(0) for
i := 0; i < threads; i++ { go func() { for { x++ } }() } time.Sleep(time.Second) fmt.Println("x =", x) }
func test() { a := 100 for i := 1;
i < 1000; i++ { a = i*100/i + a } } func main() { runtime.GOMAXPROCS(1) go func() { for { test() } }() time.Sleep(100 * time.Millisecond) fmt.Println("hello world") }
runtime: tight loops should be preemptible #10958 aclements opened this
issue on May 26, 2015 · 50 comments
Конкурентность и языки Язык Отображение на системные потоки Lua none
C, C++, Python 1:1 Java <= 1.1, j2me, Python n:1 Go, Erlang n:m
Goroutines VS threads Свойство Goroutines Threads Время создания Быстро Медленно
Время удаления Быстро Медленно Переключение контекста Быстро Медленно Потребление памяти под стек 2kB 512kB-1MB Допустимое количество 10^4 10^6
Вытесняющая и кооперативная многозадачность
Планировщики — Work Sharing при появлении новой задачи попытаться мигрировать
ее на свободный процессор — Work Stealing когда процессор освобождается, он пытается найти себе задачу
Scheduling Multithreaded Computations by Work Stealing
G M P — G - Goroutine — M -
OS thread — P - "Processor"
None
None
None
None
GOMAXPROCS Просто количество P
Spining threads — M с P ищет G — M
без P ищет P — Есть готовая к исполнению G, свободная P, но нет M
None
Когда происходит переключение goroutines — morestack() --> newstack() — runtime.Gosched()
— locks — network I/O — syscalls
GOEXPERIMENT = preemptibleloops
Влияние на GC GC не может работать пока есть невытесняемая
goroutine
https://morsmachine.dk/go-scheduler https://rakyll.org/scheduler/ https://github.com/golang/go/blob/master/src/runtime/ proc.go https://docs.google.com/document/d/ 1TTj4T2JO42uD5ID9e89oa0sLKhJYD0Y_kqxDv3I3XMw https://github.com/golang/go/issues/10958 https://github.com/golang/go/issues/16051 https://github.com/golang/go/issues/17831 https://www.slideshare.net/matthewrdale/demystifying-
the-go-scheduler https://povilasv.me/go-scheduler/