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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
73
Mobile Optimized 2014
notorca
1
270
Fun with blocks in ObjC
notorca
1
110
CocoaHeads in Grodno, Lighting
notorca
0
93
Dictionary in Python
notorca
0
130
Foundation data structures
notorca
0
170
iOS memory management
notorca
0
110
NSProxy, multithreading, messaging
notorca
1
110
Python impergections
notorca
0
94
Other Decks in Technology
See All in Technology
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
110
Spring AI × MCP 入門〜AIエージェントへのツール公開、境界設計から始める最小構成 〜
yuyamiyamoto
0
190
layerx-fde-practices
cipepser
6
2.9k
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
700
美味しいスイスチーズを作ろう🧀🐭
taigamikami
1
190
APIテストとは?
nagix
0
160
はじめてのDatadog
kairim0
0
240
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
790
AIガバナンス実践 - 生成AIコネクタのデータ漏洩リスクと実務対策
knishioka
0
150
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
地元にいないローカルオーガナイザーの立ち回り
uvb_76
1
400
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
140
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
150
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.3k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
370
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
22k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
130
Paper Plane (Part 1)
katiecoart
PRO
0
8.1k
ラッコキーワード サービス紹介資料
rakko
1
3.5M
From π to Pie charts
rasagy
0
190
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Ruling the World: When Life Gets Gamed
codingconduct
0
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/