mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: eliminate runqvictims and a copy from runqsteal
Currently, runqsteal steals Gs from another P into an intermediate buffer and then copies those Gs into the current P's run queue. This intermediate buffer itself was moved from the stack to the P in commitc4fe503to eliminate the cost of zeroing it on every steal. This commit follows upc4fe503by stealing directly into the current P's run queue, which eliminates the copy and the need for the intermediate buffer. The update to the tail pointer is only committed once the entire steal operation has succeeded, so the semantics of stealing do not change. Change-Id: Icdd7a0eb82668980bf42c0154b51eef6419fdd51 Reviewed-on: https://go-review.googlesource.com/9998 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Austin Clements <austin@google.com>
This commit is contained in:
parent
ab4e7988bb
commit
a0fc306023
2 changed files with 13 additions and 15 deletions
|
|
@ -353,10 +353,9 @@ type p struct {
|
|||
goidcacheend uint64
|
||||
|
||||
// Queue of runnable goroutines. Accessed without lock.
|
||||
runqhead uint32
|
||||
runqtail uint32
|
||||
runq [256]*g
|
||||
runqvictims [128]*g // Used to stage victims from another p's runq
|
||||
runqhead uint32
|
||||
runqtail uint32
|
||||
runq [256]*g
|
||||
// runnext, if non-nil, is a runnable G that was ready'd by
|
||||
// the current G and should be run next instead of what's in
|
||||
// runq if there's time remaining in the running G's time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue