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
620
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
59
Mobile Optimized 2014
notorca
1
260
Fun with blocks in ObjC
notorca
1
99
CocoaHeads in Grodno, Lighting
notorca
0
83
Dictionary in Python
notorca
0
120
Foundation data structures
notorca
0
150
iOS memory management
notorca
0
91
NSProxy, multithreading, messaging
notorca
1
100
Python impergections
notorca
0
87
Other Decks in Technology
See All in Technology
3分でわかる!新機能 AWS Transform custom
sato4mi
1
220
re:Inventで出たインフラエンジニアが嬉しかったアップデート
nagisa53
4
210
Databricks Free Edition講座 データサイエンス編
taka_aki
0
200
Vitest Highlights in Angular
rainerhahnekamp
0
100
それぞれのペースでやっていく Bet AI / Bet AI at Your Own Pace
yuyatakeyama
1
600
AWS Amplify Conference 2026 - 仕様からリリースまで一気通貫生成 AI 時代のフルスタック開発
inariku
3
390
習慣とAIと環境 — 技術探求を続ける3つの鍵
azukiazusa1
3
790
Amazon Bedrock AgentCore EvaluationsでAIエージェントを評価してみよう!
yuu551
0
170
Agentic Coding 実践ワークショップ
watany
41
27k
日本語テキストと音楽の対照学習の技術とその応用
lycorptech_jp
PRO
1
210
AI Agent Agentic Workflow の可観測性 / Observability of AI Agent Agentic Workflow
yuzujoe
7
2.3k
Data Intelligence on Lakehouse Paradigm
scotthsieh825
0
200
Featured
See All Featured
Code Review Best Practice
trishagee
74
19k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Site-Speed That Sticks
csswizardry
13
1k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
260
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
58
42k
Building AI with AI
inesmontani
PRO
1
650
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
Building the Perfect Custom Keyboard
takai
2
670
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
260
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
Designing Powerful Visuals for Engaging Learning
tmiket
0
210
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/