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
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
60
Mobile Optimized 2014
notorca
1
260
Fun with blocks in ObjC
notorca
1
100
CocoaHeads in Grodno, Lighting
notorca
0
83
Dictionary in Python
notorca
0
120
Foundation data structures
notorca
0
150
iOS memory management
notorca
0
91
NSProxy, multithreading, messaging
notorca
1
100
Python impergections
notorca
0
88
Other Decks in Technology
See All in Technology
SchooでVue.js/Nuxtを技術選定している理由
yamanoku
3
500
Azure Copilot Migration Agent / #jazug
koudaiii
1
150
20260204_Midosuji_Tech
takuyay0ne
1
170
デザインもAIに任せる!iPhoneで行うiOS開発
zozotech
PRO
0
190
Claude Code for NOT Programming
kawaguti
PRO
1
130
Codex 5.3 と Opus 4.6 にコーポレートサイトを作らせてみた / Codex 5.3 vs Opus 4.6
ama_ch
0
250
日本の85%が使う公共SaaSは、どう育ったのか
taketakekaho
1
270
Exadata Fleet Update
oracle4engineer
PRO
0
1.1k
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
190
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
800
Greatest Disaster Hits in Web Performance
guaca
0
330
Webhook best practices for rock solid and resilient deployments
glaforge
2
350
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
300
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Typedesign – Prime Four
hannesfritz
42
3k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
320
BBQ
matthewcrist
89
10k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
The Curse of the Amulet
leimatthew05
1
8.9k
[SF Ruby Conf 2025] Rails X
palkan
1
780
Amusing Abliteration
ianozsvald
0
110
RailsConf 2023
tenderlove
30
1.3k
Mobile First: as difficult as doing things right
swwweet
225
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/