A local queue is a runnable-goroutine queue attached to one P, the scheduler’s logical processor context. It complements the global queue when runnable goroutines cannot execute immediately. section 8.2.1
When a processor needs another goroutine, scheduling proceeds through these choices:
- Check the global runnable queue on roughly one out of every 61 executions. section 8.2.1
- Check the processor’s local queue when the global queue provides no goroutine. section 8.2.1
- Steal runnable goroutines from another processor’s local queue when both queues are empty. section 8.2.1
Figure 8.6 An example of the current state of a Go application executed on a four-core machine. Goroutines that aren’t in an executing state are either runnable (pending being executed) or waiting (pending a blocking operation).
Use the scheduler-state figure to relate Ps, Ms, Gs, local queues, the global queue, and idle capacity. section 8.2.1
runtime.schedule() {
// Only 1/61 of the time, check the global runnable queue for a G.
// If not found, check the local queue.
// If not found,
// Try to steal from other Ps.
// If not, check the global runnable queue.
// If not found, poll network.
}
Use the scheduling pseudocode to trace local-queue checks, work stealing, global-queue fallback, and network polling. section 8.2.1

