]> Cypherpunks repositories - gostls13.git/commit
runtime: stop unnecessary span scavenges on free
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 6 Nov 2018 00:10:33 +0000 (00:10 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 9 Nov 2018 20:57:57 +0000 (20:57 +0000)
commit06be7cbf3c27168172f1f89dd4f55cb07a37ec38
treec99eb7a1a940d6a36978ec690f7d081178718fe0
parent78c0e1f81d4052f8ca5a50e4e7c5bb35ddec6519
runtime: stop unnecessary span scavenges on free

This change fixes a bug wherein freeing a scavenged span that didn't
coalesce with any neighboring spans would result in that span getting
scavenged again. This case may actually be a common occurance because
"freeing" span trimmings and newly-grown spans end up using the same
codepath. On systems where madvise is relatively expensive, this can
have a large performance impact.

This change also cleans up some of this logic in freeSpanLocked since
a number of factors made the coalescing code somewhat difficult to
reason about with respect to scavenging. Notably, the way the
needsScavenge boolean is handled could be better expressed and the
inverted conditions (e.g. !after.released) can make things even more
confusing.

Fixes #28595.

Change-Id: I75228dba70b6596b90853020b7c24fbe7ab937cf
Reviewed-on: https://go-review.googlesource.com/c/147559
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mheap.go