Skip to main content

Advanced Go

Mastering the Go Scheduler: A Deep Dive into Goroutines and the G-M-P Model

Introduction # If you have been writing Go for any length of time, you likely know the “magic” of the language: put the keyword go in front of a function, and it runs concurrently. It feels almost free. You can spawn 100,000 goroutines on a standard laptop, and the program just hums along. Try doing that with Java threads or OS pthreads, and your machine will likely grind to a halt before you hit 10,000.