mirror of
https://github.com/golang/go
synced 2024-11-08 07:26:11 -07:00
runtime: batch moving gFree list between local p and global schedt
Change-Id: I0ca1fcee6d3f08bdfcfa51f0dc774118d7355636 Reviewed-on: https://go-review.googlesource.com/c/go/+/271914 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
bcac57f89c
commit
1f7a01459b
@ -4170,17 +4170,25 @@ func gfput(_p_ *p, gp *g) {
|
|||||||
_p_.gFree.push(gp)
|
_p_.gFree.push(gp)
|
||||||
_p_.gFree.n++
|
_p_.gFree.n++
|
||||||
if _p_.gFree.n >= 64 {
|
if _p_.gFree.n >= 64 {
|
||||||
lock(&sched.gFree.lock)
|
var (
|
||||||
|
inc int32
|
||||||
|
stackQ gQueue
|
||||||
|
noStackQ gQueue
|
||||||
|
)
|
||||||
for _p_.gFree.n >= 32 {
|
for _p_.gFree.n >= 32 {
|
||||||
_p_.gFree.n--
|
|
||||||
gp = _p_.gFree.pop()
|
gp = _p_.gFree.pop()
|
||||||
|
_p_.gFree.n--
|
||||||
if gp.stack.lo == 0 {
|
if gp.stack.lo == 0 {
|
||||||
sched.gFree.noStack.push(gp)
|
noStackQ.push(gp)
|
||||||
} else {
|
} else {
|
||||||
sched.gFree.stack.push(gp)
|
stackQ.push(gp)
|
||||||
}
|
}
|
||||||
sched.gFree.n++
|
inc++
|
||||||
}
|
}
|
||||||
|
lock(&sched.gFree.lock)
|
||||||
|
sched.gFree.noStack.pushAll(noStackQ)
|
||||||
|
sched.gFree.stack.pushAll(stackQ)
|
||||||
|
sched.gFree.n += inc
|
||||||
unlock(&sched.gFree.lock)
|
unlock(&sched.gFree.lock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4232,17 +4240,25 @@ retry:
|
|||||||
|
|
||||||
// Purge all cached G's from gfree list to the global list.
|
// Purge all cached G's from gfree list to the global list.
|
||||||
func gfpurge(_p_ *p) {
|
func gfpurge(_p_ *p) {
|
||||||
lock(&sched.gFree.lock)
|
var (
|
||||||
|
inc int32
|
||||||
|
stackQ gQueue
|
||||||
|
noStackQ gQueue
|
||||||
|
)
|
||||||
for !_p_.gFree.empty() {
|
for !_p_.gFree.empty() {
|
||||||
gp := _p_.gFree.pop()
|
gp := _p_.gFree.pop()
|
||||||
_p_.gFree.n--
|
_p_.gFree.n--
|
||||||
if gp.stack.lo == 0 {
|
if gp.stack.lo == 0 {
|
||||||
sched.gFree.noStack.push(gp)
|
noStackQ.push(gp)
|
||||||
} else {
|
} else {
|
||||||
sched.gFree.stack.push(gp)
|
stackQ.push(gp)
|
||||||
}
|
}
|
||||||
sched.gFree.n++
|
inc++
|
||||||
}
|
}
|
||||||
|
lock(&sched.gFree.lock)
|
||||||
|
sched.gFree.noStack.pushAll(noStackQ)
|
||||||
|
sched.gFree.stack.pushAll(stackQ)
|
||||||
|
sched.gFree.n += inc
|
||||||
unlock(&sched.gFree.lock)
|
unlock(&sched.gFree.lock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user