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
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
57
Mobile Optimized 2014
notorca
1
260
Fun with blocks in ObjC
notorca
1
99
CocoaHeads in Grodno, Lighting
notorca
0
83
Dictionary in Python
notorca
0
120
Foundation data structures
notorca
0
140
iOS memory management
notorca
0
91
NSProxy, multithreading, messaging
notorca
1
100
Python impergections
notorca
0
86
Other Decks in Technology
See All in Technology
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
2
440
Keynoteから見るAWSの頭の中
nrinetcom
PRO
1
110
Building Serverless AI Memory with Mastra × AWS
vvatanabe
1
730
Authlete で実装する MCP OAuth 認可サーバー #CIMD の実装を添えて
watahani
0
230
Snowflake Industry Days 2025 Nowcast
takumimukaiyama
0
140
20251218_AIを活用した開発生産性向上の全社的な取り組みの進め方について / How to proceed with company-wide initiatives to improve development productivity using AI
yayoi_dd
0
790
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
9.9k
まだ間に合う! Agentic AI on AWSの現在地をやさしく一挙おさらい
minorun365
19
3.1k
AIBuildersDay_track_A_iidaxs
iidaxs
4
1.5k
20251222_サンフランシスコサバイバル術
ponponmikankan
2
150
日本の AI 開発と世界の潮流 / GenAI Development in Japan
hariby
2
640
2025年のデザインシステムとAI 活用を振り返る
leveragestech
0
410
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
260
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
190
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
90
Amusing Abliteration
ianozsvald
0
76
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
300
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
Evolving SEO for Evolving Search Engines
ryanjones
0
82
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Crafting Experiences
bethany
0
23
Test your architecture with Archunit
thirion
1
2.1k
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/