Queues, Fairness, and The Go Scheduler
summary
Explains how Go 1.17.2 maps millions of goroutines onto threads using P/M/G with per-P local run queues of 256-local run length, a global run queue, and work stealing; shows non‑cooperative preemption at 10ms preemption delivered by the runtime daemon cismon via a user signal; justifies the 61 hardcoded schedtick (prime to avoid frequency collisions); demos a tool that enables runtime schedtrace, exports metrics to Prometheus/Grafana, and successfully visualizes steals, preempts, and queue dynamics.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 1:15Disclaimer
- 4:12User Space Scheduling
- 5:50Global Run Queue
- 6:50Fairness
- 8:43Distributed run queues
- 9:33Go max prox
- 12:55Fairness in scheduling
- 18:03The netpolar
- 24:11Demo
- 37:09Prime
- 38:13Prime Graph
- 38:56Handoff
- 41:14Scheduling
- 42:17Runtime APIs
- 43:43Lock OS Thread
- 45:07Lock OS Thread Debugging
- 45:32Lock OS Case Study
- 46:20Conclusion
related talks
22mTales of Go Runtime Scheduler
14mDr Gopher, Anatomy of the Scheduler
14mGo's work stealing scheduler
49mDeep dive into the Go scheduler, or Why would I steal goroutines?
42mRuntime scheduling: theory and reality
50mUnderstanding the Go runtime
40mDebugging concurrency programs in Go
26mPardon the Interruption: Loop Preemption in Go 1.14
