runtime: add goroutines returned by poller to local run queue In Go 1.13, when the network poller found a list of ready goroutines, they were added to the global run queue. The timer goroutine would typically sleep in a futex with a timeout, and when the timeout expired the timer goroutine would either be handed off to an idle P or added to the global run queue. The effect was that on a busy system with no idle P's goroutines waiting for timeouts and goroutines waiting for the network would start at the same priority. That changed on tip with the new timer code. Now timer functions are invoked directly from a P, and it happens that the functions used by time.Sleep and time.After and time.Ticker add the newly ready goroutines to the local run queue. When a P looks for work it will prefer goroutines on the local run queue; in fact it will only occasionally look at the global run queue, and even when it does it will just pull one goroutine off. So on a busy system with both active timers and active network connections the system can noticeably prefer to run goroutines waiting for timers rather than goroutines waiting for the network. This CL undoes that change by, when possible, adding goroutines waiting for the network to the local run queue of the P that checked. This doesn't affect network poller checks done by sysmon, but it does affect network poller checks done as each P enters the scheduler. This CL also makes injecting a list into either the local or global run queue more efficient, using bulk operations rather than individual ones. Change-Id: I85a66ad74e4fc3b458256fb7ab395d06f0d2ffac Reviewed-on: https://go-review.googlesource.com/c/go/+/216198 Reviewed-by: Michael Knyszek <mknyszek@google.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.