Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Go Scheduler
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Cyril Lashkevich
July 21, 2017
Technology
660
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go Scheduler
GoWayFest 2017
Cyril Lashkevich
July 21, 2017
Transcript
22 slides
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/
More Decks by Cyril Lashkevich
See All by Cyril Lashkevich
Bitcode in Swift
notorca
0
91
Mobile Optimized 2014
notorca
1
300
Fun with blocks in ObjC
notorca
1
120
CocoaHeads in Grodno, Lighting
notorca
0
110
Dictionary in Python
notorca
0
150
Foundation data structures
notorca
0
180
iOS memory management
notorca
0
140
NSProxy, multithreading, messaging
notorca
1
130
Python impergections
notorca
0
110
Other Decks in Technology
See All in Technology
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.2k
パスワードのない鍵で、 データを手元に置く
ginjihayashi
0
370
[NW-JAWS DAY]「うちのAWS、インターネット出られないんで」― AWS外の自社サービスをPrivateLinkでシュッと公開する方法
ykimi
3
880
AIネイティブ組織の作り方。1人のPOとAIから始める、自社での実験
ama_ch
2
1.2k
AWS Client VPNの設定でハマったポイントとその過程での気づき
amarelo_n24
1
400
落とし穴にハマってわかった 開発生産性を測るときに気をつけたいこと
munakata
3
420
マネジメントされる側の仕事は「文句」を言うこと
riyaamemiya
7
5.8k
共通基盤の実装に Kotlin - Quarkus を選定した理由と採用したアーキテクチャ
nealle
1
140
サーバーラックは作る時代! 3Dプリンターで作る10インチラックのススメ
jacopen
2
470
小さなエージェントから始めてみよう!実践コンテキストエンジニアリング
iwamot
PRO
0
130
認知負荷の減らし方 ~開発にも日常業務にも活かせるノウハウ~
minorun365
PRO
3
2.7k
RAGの改善を速く回すための評価基盤
yosukeyoshida
6
3.3k
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
290
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
320
Paper Plane
katiecoart
PRO
6
55k
Technical Leadership for Architectural Decision Making
baasie
4
650
The Pragmatic Product Professional
lauravandoore
37
7.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Deep Space Network (abreviated)
tonyrice
0
420
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Utilizing Notion as your number one productivity tool
mfonobong
4
650
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.8k