Runtime i Go përfshin një planifikues që multiplekson shumë goroutinat në një numër të vogël tema të SO. Kjo planifikim M:N (M goroutina në N tema të SO) është ajo që i bën goroutinat kaq të lira dhe konkurencën e Go kaq të shkallëzueshme. Të kuptimit të tij shpjegon performancën e goroutinave.
Modeli 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.
