Go runtime मध्ये scheduler असतो जो अनेक goroutines लाई कमी संख्येच्या OS threads वर multiplex करतो. हे M:N scheduling (M goroutines on N OS threads) असे आहे जे goroutines ला इतके स्वस्त आणि Go च्या concurrency ला इतके scalable बनवते. याचे समज goroutine performance स्पष्ट करते.
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.
