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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Cyril Lashkevich
July 21, 2017
Technology
2
620
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
62
Mobile Optimized 2014
notorca
1
270
Fun with blocks in ObjC
notorca
1
100
CocoaHeads in Grodno, Lighting
notorca
0
86
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
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
160
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
開発チームとQAエンジニアの新しい協業モデル -年末調整開発チームで実践する【QAリード施策】-
kaomi_wombat
0
260
夢の無限スパゲッティ製造機 #phperkaigi
o0h
PRO
0
380
SaaSに宿る21g
kanyamaguc
2
180
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
270
データマネジメント戦略Night - 4社のリアルを語る会
ktatsuya
1
420
【AWS】CloudTrail LakeとCloudWatch Logs Insightsの使い分け方針
tsurunosd
0
120
私がよく使うMCPサーバー3選と社内で安全に活用する方法
kintotechdev
0
130
DMBOKを使ってレバレジーズのデータマネジメントを評価した
leveragestech
0
440
AWS Systems Managerのハイブリッドアクティベーションを使用したガバメントクラウド環境の統合管理
toru_kubota
1
180
Phase06_ClaudeCode実践
overflowinc
0
2.3k
Featured
See All Featured
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.5k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
300
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
480
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
250
Docker and Python
trallard
47
3.8k
Scaling GitHub
holman
464
140k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
780
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
230
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
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/