Schedgroup: a Timer-Based Goroutine Concurrency Primitive
summary
Introduces schedgroup, a Go package that schedules goroutines by time and supports context cancellation, evolving from three prototypes: one timer per goroutine, timer-polling with a min-heap, and an event-driven monitor with one time.Timer and container/heap. Uses channels, select, non-blocking notify, and time.Timer to spawn goroutines on demand; in a benchmark scheduling 1,000,000 tasks it reduces parked goroutines from ~1,000,000 to 3 and cuts heap memory ~6×, and the final design runs in production.
AI-written summary · about
chapters (5)
- 0:00Start
- 7:38manage a central timer
- 11:36push a new task onto the heap
- 12:44wait for context cancellation or for addition of a new task
- 16:39examine the in use heap space
related talks
22mTales of Go Runtime Scheduler
47mQueues, Fairness, and The Go Scheduler
24mMastering Concurrency in Go: From Patterns to Production
27mProduction Ready Concurrency
49mDeep dive into the Go scheduler, or Why would I steal goroutines?
26mConcurrency primitives of Golang - how to use and how not to
16mIn the Land of Gophers (from Age 3)
12mComposing Schedulers using Effect Handlers
