]> Cypherpunks repositories - gostls13.git/commit
runtime: fix CPU underutilization
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 27 Jun 2013 16:52:12 +0000 (20:52 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 27 Jun 2013 16:52:12 +0000 (20:52 +0400)
commit15a1c3d1e46393a0b05ef5f518d1f4d0b7c638b8
tree8c1105d3f4f89c1cef004796fada9d0d9045ad7f
parenteac6bee7c1aba48dd4f677dc354acba003d75d41
runtime: fix CPU underutilization
runtime.newproc/ready are deliberately sloppy about waking new M's,
they only ensure that there is at least 1 spinning M.
Currently to compensate for that, schedule() checks if the current P
has local work and there are no spinning M's, it wakes up another one.
It does not work if goroutines do not call schedule.
With this change a spinning M wakes up another M when it finds work to do.
It's also not ideal, but it fixes the underutilization.
A proper check would require to know the exact number of runnable G's,
but it's too expensive to maintain.
Fixes #5586.

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/9776044
src/pkg/runtime/proc.c
src/pkg/runtime/proc_test.go