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
640
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go Scheduler
GoWayFest 2017
Cyril Lashkevich
July 21, 2017
More Decks by Cyril Lashkevich
See All by Cyril Lashkevich
Bitcode in Swift
notorca
0
75
Mobile Optimized 2014
notorca
1
280
Fun with blocks in ObjC
notorca
1
110
CocoaHeads in Grodno, Lighting
notorca
0
99
Dictionary in Python
notorca
0
140
Foundation data structures
notorca
0
170
iOS memory management
notorca
0
120
NSProxy, multithreading, messaging
notorca
1
110
Python impergections
notorca
0
100
Other Decks in Technology
See All in Technology
【CEDEC2026】ゲームシナリオライターを支援するAIツール開発の実践 ― 設計とプロンプトの工夫 ―
cygames
PRO
1
730
OSPN.JPバージョンアップ作業進捗のご報告 / 20260801-osc26kyoto
akkiesoft
0
270
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
510
Software Supply Chain Attackからクラウド環境を守るためにできること
lhazy
2
130
サイバー捜査員研修(後半)
nomizone
1
690
【CEDEC2026】専門性の高いデフォルメチームが挑んだ人材育成戦略 〜Cygames Academiaの企画から実施まで〜
cygames
PRO
0
440
Flutterをカメラで動かしたかった話
sony
0
120
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
ガバメントクラウドでのランサムウェア対策
techniczna
1
790
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
200
Agent 時代の Kaggle 展望 / kaggle-in-the-agentic-era
upura
0
370
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
16
5.9k
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Building the Perfect Custom Keyboard
takai
2
830
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
WENDY [Excerpt]
tessaabrams
11
39k
The Cult of Friendly URLs
andyhume
79
7k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
A better future with KSS
kneath
240
18k
A designer walks into a library…
pauljervisheath
211
24k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
240
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/