Senior
Kuhu lähevad gorutined loodud — Go planeerija kohalikku või globaalset järjekorda?
sobes.tech AI
Vastus AI-lt
When creating a goroutine in Go, it is placed into the local run queue, which belongs to a specific M (machine, system thread).
Go runtime uses an M:N model, where M are system threads and G are goroutines. Each M has its own local goroutine queue for execution. If the local queue overflows or is empty, the scheduler can balance goroutines between the local and global queues.
Thus, a new goroutine is initially placed in the scheduler's local queue, allowing efficient use of the processor cache and reducing context switch costs.