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
620
2
Share
Go Scheduler
GoWayFest 2017
Cyril Lashkevich
July 21, 2017
More Decks by Cyril Lashkevich
See All by Cyril Lashkevich
Bitcode in Swift
notorca
0
63
Mobile Optimized 2014
notorca
1
270
Fun with blocks in ObjC
notorca
1
100
CocoaHeads in Grodno, Lighting
notorca
0
87
Dictionary in Python
notorca
0
130
Foundation data structures
notorca
0
150
iOS memory management
notorca
0
93
NSProxy, multithreading, messaging
notorca
1
110
Python impergections
notorca
0
92
Other Decks in Technology
See All in Technology
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
190
Proxmox超入門
devops_vtj
0
180
システムは「動く」だけでは 足りない - 非機能要件・分散システム・トレードオフの基礎
nwiizo
26
8.5k
GitHub Copilotを極める会 - 開発者のための活用術
findy_eventslides
7
4.1k
ストライクウィッチーズ2期6話のエイラの行動が許せないのでPjMの観点から何をすべきだったのかを考える
ichimichi
1
360
AgentCore RuntimeからS3 Filesをマウントしてみる
har1101
3
410
BigQuery × dbtでコスト削減した話
rightcode
0
110
OBI+APMでお手軽にアプリケーションのオブザーバビリティを手に入れよう
kenshimuto
0
260
Zero-Downtime Migration: Moving a Massive, Historic iOS App from CocoaPods to SPM and Tuist without Stopping Feature Delivery
kagemiku
0
230
建設的な現実逃避のしかた / How to practice constructive escapism
pauli
4
320
"SQLは書けません"から始まる データドリブン
kubell_hr
2
350
さくらのクラウドでつくるCloudNative Daysのオブザーバビリティ基盤
b1gb4by
0
160
Featured
See All Featured
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
410
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
190
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
210
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
The Curse of the Amulet
leimatthew05
1
11k
Tell your own story through comics
letsgokoyo
1
890
Speed Design
sergeychernyshev
33
1.6k
Un-Boring Meetings
codingconduct
0
260
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Faster Mobile Websites
deanohume
310
31k
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/