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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
60
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
88
Other Decks in Technology
See All in Technology
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
Cosmos World Foundation Model Platform for Physical AI
takmin
0
770
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
150
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
460
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
42k
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
160
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
420
20260208_第66回 コンピュータビジョン勉強会
keiichiito1978
0
110
プロポーザルに込める段取り八分
shoheimitani
1
190
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
230
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
180
Designing for humans not robots
tammielis
254
26k
Design in an AI World
tapps
0
140
Visualization
eitanlees
150
17k
A Tale of Four Properties
chriscoyier
162
24k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
49k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
Utilizing Notion as your number one productivity tool
mfonobong
3
220
The SEO identity crisis: Don't let AI make you average
varn
0
67
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
AI: The stuff that nobody shows you
jnunemaker
PRO
2
250
Practical Orchestrator
shlominoach
191
11k
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/