4 ms·
> When a system call is invoked, until it finishes, it is true that the caller goroutine will be parked with a system thread, however, the thread will detach it
by valyala 8y ago
> When a system call is invoked, until it finishes, it is true that the caller goroutine will be parked with a system thread, however, the thread will detach itself from a P, so that the P can assign other goroutines (G) to other threads. So there is no CPU under-utilization.
True. But major page fault doesn't invoke syscall. Go program just accesses regular memory inside mmap'ed region while running on logical processor (P). Go runtime doesn't know anything about the hard page fault, so cannot add an additional OS thread like in the syscall case.
- tapirl 8y agoAh, so setting GOMAXPROCS with a value larger than NumCPUs is good for the performance of a program sometimes. Glad that I learned something new. Thanks for this article.