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
610
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
46
Mobile Optimized 2014
notorca
1
260
Fun with blocks in ObjC
notorca
1
90
CocoaHeads in Grodno, Lighting
notorca
0
81
Dictionary in Python
notorca
0
110
Foundation data structures
notorca
0
140
iOS memory management
notorca
0
87
NSProxy, multithreading, messaging
notorca
1
92
Python impergections
notorca
0
79
Other Decks in Technology
See All in Technology
AIドリブンのソフトウェア開発 - うまいやり方とまずいやり方
okdt
PRO
9
720
コスト削減の基本の「キ」~ コスト消費3大リソースへの対策 ~
smt7174
2
280
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.6k
そのコンポーネント、サーバー?クライアント?App Router開発のモヤモヤを可視化する補助輪
makotot
4
750
事業価値と Engineering
recruitengineers
PRO
6
4.3k
新規案件の立ち上げ専門チームから見たAI駆動開発の始め方
shuyakinjo
0
490
知られざるprops命名の慣習 アクション編
uhyo
11
2.7k
実践データベース設計 ①データベース設計概論
recruitengineers
PRO
4
1.5k
実践アプリケーション設計 ③ドメイン駆動設計
recruitengineers
PRO
11
2.7k
Jaws-ug名古屋_LT資料_20250829
azoo2024
3
180
Evolution on AI Agent and Beyond - AGI への道のりと、シンギュラリティの3つのシナリオ
masayamoriofficial
0
260
衝突して強くなる! BLUE GIANTと アジャイルチームの共通点とは ― いきいきと活気に満ちたグルーヴあるチームを作るコツ ― / BLUE GIANT and Agile Teams
naitosatoshi
0
190
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
284
13k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
Scaling GitHub
holman
462
140k
Designing Experiences People Love
moore
142
24k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Six Lessons from altMBA
skipperchong
28
4k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
20k
Rails Girls Zürich Keynote
gr2m
95
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
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/