Runtime-ul Go include un planificator care mapează multe goroutine-uri pe un număr mic de thread-uri OS. Această planificare M:N (M goroutine-uri pe N thread-uri OS) este ceea ce face goroutine-urile atât de ieftine și concurența Go atât de scalabilă. Înțelegerea sa explică performanța goroutine-urilor.
Modelul G-M-P
G (Goroutine) — your concurrent task (lightweight, ~2KB stack to start)
M (Machine) — an OS thread (the actual thread the OS schedules)
P (Processor) — a logical processor / scheduling context; holds a queue of runnable Gs
(the number of P's = GOMAXPROCS, default = number of CPU cores)
The scheduler runs G's on M's, coordinated through P's:
Each P has a local run queue of goroutines; an M must hold a P to run G's.
