Go runtime apima planuotoją, kuris sąryšyje jungia daugybę goroutinių su mažu skaičiumi OS gijų. Šis M:N planaviimas (M goroutinių ant N OS gijų) yra tai, dėl ko goroutinės yra tokios pigios ir Go lygiagretumas toks mastelis. Jį supratę, paaiškinsitės goroutinės efektyvumą.
G-M-P modelis
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.
