Go runtime-ი მოიცავს scheduler-ს, რომელიც ბევრი goroutine-ს ოპერაციულ სისტემის ცოტა რაოდენობის thread-ზე აერთიანებს. ეს M:N scheduling (M goroutine-ი N OS thread-ზე) არის ის, რაც goroutine-ებს ისე იაფს და Go-ს concurrency-ს ისე მასშტაბირებადს ხდის. მისი გაგება აგიხსნით goroutine-ის შესრულების ხარისხს.
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.
