3 ms·
To stop the world, Go preempts at the next stack size check [1], which happens during function call preludes. I guess that happens often enough to be fast in pr
by pcwalton 10y ago
To stop the world, Go preempts at the next stack size check [1], which happens during function call preludes. I guess that happens often enough to be fast in practice.
[1]: https://github.com/golang/go/blob/8f81dfe8b47e975b90bb4a2f8dd314d32c633176/src/runtime/proc.go#L3900 https://github.com/golang/go/blob/8f81dfe8b47e975b90bb4a2f8d...
- rayiner 10y agoI assume this works so quickly in part because goroutines are backed by a pool of OS threads that don't block? So everybody doesn't get stuck waiting for a thread that's blocked to get around to checking the preemption flag?
- pcwalton 10y agoRight, blocked threads are stopped in the userspace scheduler so there are no synchronization issues with just keeping them stopped.