mirror of
https://github.com/golang/go
synced 2024-11-18 15:44:41 -07:00
Revert "runtime: bound defer pools"
This reverts commit 8059071153
.
Conflicts:
src/runtime/proc1.go (resolved by hand)
Change-Id: Ic62e3e802f0007ff9012b37bc5fd41fcafc153d0
Reviewed-on: https://go-review.googlesource.com/3885
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
This commit is contained in:
parent
1f2d7bf44f
commit
7505cd8b23
@ -25,21 +25,6 @@ func clearpools() {
|
||||
poolcleanup()
|
||||
}
|
||||
|
||||
// Clear central defer pools.
|
||||
// Leave per-P pools alone, they have strictly bounded size.
|
||||
lock(&sched.deferlock)
|
||||
for i := range sched.deferpool {
|
||||
// disconnect cached list before dropping it on the floor,
|
||||
// so that a dangling ref to one entry does not pin all of them.
|
||||
var d, dlink *_defer
|
||||
for d = sched.deferpool[i]; d != nil; d = dlink {
|
||||
dlink = d.link
|
||||
d.link = nil
|
||||
}
|
||||
sched.deferpool[i] = nil
|
||||
}
|
||||
unlock(&sched.deferlock)
|
||||
|
||||
for _, p := range &allp {
|
||||
if p == nil {
|
||||
break
|
||||
@ -58,6 +43,18 @@ func clearpools() {
|
||||
}
|
||||
c.sudogcache = nil
|
||||
}
|
||||
|
||||
// clear defer pools
|
||||
for i := range p.deferpool {
|
||||
// disconnect cached list before dropping it on the floor,
|
||||
// so that a dangling ref to one entry does not pin all of them.
|
||||
var d, dlink *_defer
|
||||
for d = p.deferpool[i]; d != nil; d = dlink {
|
||||
dlink = d.link
|
||||
d.link = nil
|
||||
}
|
||||
p.deferpool[i] = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,20 +166,9 @@ func newdefer(siz int32) *_defer {
|
||||
mp := acquirem()
|
||||
if sc < uintptr(len(p{}.deferpool)) {
|
||||
pp := mp.p
|
||||
if len(pp.deferpool[sc]) == 0 {
|
||||
lock(&sched.deferlock)
|
||||
for len(pp.deferpool[sc]) < cap(pp.deferpool[sc])/2 && sched.deferpool[sc] != nil {
|
||||
d := sched.deferpool[sc]
|
||||
sched.deferpool[sc] = d.link
|
||||
d.link = nil
|
||||
pp.deferpool[sc] = append(pp.deferpool[sc], d)
|
||||
}
|
||||
unlock(&sched.deferlock)
|
||||
}
|
||||
if ln := len(pp.deferpool[sc]); ln > 0 {
|
||||
d = pp.deferpool[sc][ln-1]
|
||||
pp.deferpool[sc][ln-1] = nil
|
||||
pp.deferpool[sc] = pp.deferpool[sc][:ln-1]
|
||||
d = pp.deferpool[sc]
|
||||
if d != nil {
|
||||
pp.deferpool[sc] = d.link
|
||||
}
|
||||
}
|
||||
if d == nil {
|
||||
@ -225,28 +214,9 @@ func freedefer(d *_defer) {
|
||||
if sc < uintptr(len(p{}.deferpool)) {
|
||||
mp := acquirem()
|
||||
pp := mp.p
|
||||
if len(pp.deferpool[sc]) == cap(pp.deferpool[sc]) {
|
||||
// Transfer half of local cache to the central cache.
|
||||
var first, last *_defer
|
||||
for len(pp.deferpool[sc]) > cap(pp.deferpool[sc])/2 {
|
||||
ln := len(pp.deferpool[sc])
|
||||
d := pp.deferpool[sc][ln-1]
|
||||
pp.deferpool[sc][ln-1] = nil
|
||||
pp.deferpool[sc] = pp.deferpool[sc][:ln-1]
|
||||
if first == nil {
|
||||
first = d
|
||||
} else {
|
||||
last.link = d
|
||||
}
|
||||
last = d
|
||||
}
|
||||
lock(&sched.deferlock)
|
||||
last.link = sched.deferpool[sc]
|
||||
sched.deferpool[sc] = first
|
||||
unlock(&sched.deferlock)
|
||||
}
|
||||
*d = _defer{}
|
||||
pp.deferpool[sc] = append(pp.deferpool[sc], d)
|
||||
d.link = pp.deferpool[sc]
|
||||
pp.deferpool[sc] = d
|
||||
releasem(mp)
|
||||
}
|
||||
}
|
||||
|
@ -2470,9 +2470,6 @@ func procresize(nprocs int32) *p {
|
||||
pp = new(p)
|
||||
pp.id = i
|
||||
pp.status = _Pgcstop
|
||||
for i := range pp.deferpool {
|
||||
pp.deferpool[i] = pp.deferpoolbuf[i][:0]
|
||||
}
|
||||
atomicstorep(unsafe.Pointer(&allp[i]), unsafe.Pointer(pp))
|
||||
}
|
||||
if pp.mcache == nil {
|
||||
@ -2511,13 +2508,6 @@ func procresize(nprocs int32) *p {
|
||||
}
|
||||
sched.runqsize++
|
||||
}
|
||||
for i := range p.deferpool {
|
||||
for j := range p.deferpoolbuf[i] {
|
||||
p.deferpoolbuf[i][j] = nil
|
||||
}
|
||||
p.deferpool[i] = p.deferpoolbuf[i][:0]
|
||||
}
|
||||
|
||||
freemcache(p.mcache)
|
||||
p.mcache = nil
|
||||
gfpurge(p)
|
||||
|
@ -314,9 +314,7 @@ type p struct {
|
||||
syscalltick uint32 // incremented on every system call
|
||||
m *m // back-link to associated m (nil if idle)
|
||||
mcache *mcache
|
||||
|
||||
deferpool [5][]*_defer // pool of available defer structs of different sizes (see panic.go)
|
||||
deferpoolbuf [5][32]*_defer
|
||||
deferpool [5]*_defer // pool of available defer structs of different sizes (see panic.c)
|
||||
|
||||
// Cache of goroutine ids, amortizes accesses to runtime·sched.goidgen.
|
||||
goidcache uint64
|
||||
@ -367,9 +365,6 @@ type schedt struct {
|
||||
gfree *g
|
||||
ngfree int32
|
||||
|
||||
deferlock mutex
|
||||
deferpool [5]*_defer // central pool of available defer structs of different sizes
|
||||
|
||||
gcwaiting uint32 // gc is waiting to run
|
||||
stopwait int32
|
||||
stopnote note
|
||||
|
Loading…
Reference in New Issue
Block a user