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
460
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
37
Mobile Optimized 2014
notorca
1
250
Fun with blocks in ObjC
notorca
1
67
CocoaHeads in Grodno, Lighting
notorca
0
70
Dictionary in Python
notorca
0
84
Foundation data structures
notorca
0
120
iOS memory management
notorca
0
70
NSProxy, multithreading, messaging
notorca
1
79
Python impergections
notorca
0
55
Other Decks in Technology
See All in Technology
GraphQL 成熟度モデルの紹介と、プロダクトに当てはめた事例 / GraphQL maturity model
mh4gf
7
1.2k
ServiceNow Knowledge Learning Rise up
manarobot
0
190
EMとして2023年度に頑張ったこと / What we did well in FY2023 as a EM
pauli
1
150
日本におけるデータエンジニアリングのこれまでとこれから
foursue
16
4k
オーナーシップを持つ領域を明確にする
konifar
13
3k
MLOpsの「壁」を乗り越える、LINEヤフーの Data Quality as Code
lycorptech_jp
PRO
3
120
2024/4/26 コンピュータ歴史博物館解説告知
toshi_atsumi
0
210
カオナビの利用実績をアウトカムへつなげる旅 / example-of-data-management-startup-in-kaonavi
kaonavi
0
130
〜小さく始めて大きく育てる〜データ分析基盤の開発から活用まで
kniino
0
2.1k
推しは推せるときに推せ! プロダクトにフィードバックしていこう
nakasho
0
240
アクセス制御にまつわる改善 / Improving access control
itkq
0
480
自動生成を活用した、運用保守コストを抑える Error/Alert/Runbook の一元集約管理 / Centralized management of Error/Alert/Runbook to minimize operational costs using automated code generation
biwashi
12
2.3k
Featured
See All Featured
A Philosophy of Restraint
colly
196
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
321
20k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Music & Morning Musume
bryan
41
5.6k
Documentation Writing (for coders)
carmenintech
59
3.9k
Unsuck your backbone
ammeep
662
57k
Typedesign – Prime Four
hannesfritz
36
2.1k
Atom: Resistance is Futile
akmur
258
25k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
243
20k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
119
39k
Adopting Sorbet at Scale
ufuk
67
8.6k
What the flash - Photography Introduction
edds
64
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/