GMP — Goroutine (G), Machine (M), Processor (P). Go's scheduler for efficient concurrency.
Components:
1// Check GOMAXPROCS2fmt.Println("GOMAXPROCS:", runtime.GOMAXPROCS(0))3fmt.Println("NumCPU:", runtime.NumCPU())45// Runtime hints6runtime.Gosched() // Yield7runtime.LockOSThread() // Pin to thread
Work stealing:
Handoff:
When to tune:
Common mistakes:
GOMAXPROCS(0) (read) with setting.LockOSThread() without need.