Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
54
Mobile Optimized 2014
notorca
1
260
Fun with blocks in ObjC
notorca
1
97
CocoaHeads in Grodno, Lighting
notorca
0
82
Dictionary in Python
notorca
0
120
Foundation data structures
notorca
0
140
iOS memory management
notorca
0
90
NSProxy, multithreading, messaging
notorca
1
100
Python impergections
notorca
0
85
Other Decks in Technology
See All in Technology
JEDAI認定プログラム JEDAI Order 2026 エントリーのご案内 / JEDAI Order 2026 Entry
databricksjapan
0
130
打 造 A I 驅 動 的 G i t H u b ⾃ 動 化 ⼯ 作 流 程
appleboy
0
350
AI-DLCを現場にインストールしてみた:プロトタイプ開発で分かったこと・やめたこと
recruitengineers
PRO
2
150
Lookerで実現するセキュアな外部データ提供
zozotech
PRO
0
150
NIKKEI Tech Talk #41: セキュア・バイ・デザインからクラウド管理を考える
sekido
PRO
0
120
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
12
5.7k
Oracle Cloud Infrastructure IaaS 新機能アップデート 2025/09 - 2025/11
oracle4engineer
PRO
0
160
Database イノベーショントークを振り返る/reinvent-2025-database-innovation-talk-recap
emiki
0
220
ガバメントクラウド利用システムのライフサイクルについて
techniczna
0
190
AWS re:Invent 2025で見たGrafana最新機能の紹介
hamadakoji
0
400
2025年 開発生産「可能」性向上報告 サイロ解消からチームが能動性を獲得するまで/ 20251216 Naoki Takahashi
shift_evolve
PRO
1
200
エンジニアリングをやめたくないので問い続ける
estie
2
1.2k
Featured
See All Featured
Building an army of robots
kneath
306
46k
GitHub's CSS Performance
jonrohan
1032
470k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
BBQ
matthewcrist
89
9.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Rails Girls Zürich Keynote
gr2m
95
14k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
970
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
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/