aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mstats.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-07-23 22:36:58 +0000
committerMichael Knyszek <mknyszek@google.com>2020-10-26 17:26:40 +0000
commitd677899e903c4741920846f1af2c14c56f6e710e (patch)
treee054e41c7b55bc75e514c3846ee9c048258e38c2 /src/runtime/mstats.go
parentcca3d1e5533cb40beb9ef55bbc332b733adcc6ba (diff)
downloadgo-d677899e903c4741920846f1af2c14c56f6e710e.tar.gz
go-d677899e903c4741920846f1af2c14c56f6e710e.zip
runtime: flush local_scan directly and more often
Now that local_scan is the last mcache-based statistic that is flushed by purgecachedstats, and heap_scan and gcController.revise may be interacted with concurrently, we don't need to flush heap_scan at arbitrary locations where the heap is locked, and we don't need purgecachedstats and cachestats anymore. Instead, we can flush local_scan at the same time we update heap_live in refill, so the two updates may share the same revise call. Clean up unused functions, remove code that would cause the heap to get locked in the allocSpan when it didn't need to (other than to flush local_scan), and flush local_scan explicitly in a few important places. Notably we need to flush local_scan whenever we flush the other stats, but it doesn't need to be donated anywhere, so have releaseAll do the flushing. Also, we need to flush local_scan before we set heap_scan at the end of a GC, which was previously handled by cachestats. Just do so explicitly -- it's not much code and it becomes a lot more clear why we need to do so. Change-Id: I35ac081784df7744d515479896a41d530653692d Reviewed-on: https://go-review.googlesource.com/c/go/+/246968 Run-TryBot: Michael Knyszek <mknyszek@google.com> Trust: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mstats.go')
-rw-r--r--src/runtime/mstats.go25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index 341906fced..5eeb173640 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -556,9 +556,6 @@ func updatememstats() {
memstats.by_size[i].nfree = 0
}
- // Aggregate local stats.
- cachestats()
-
// Collect allocation stats. This is safe and consistent
// because the world is stopped.
var smallFree, totalAlloc, totalFree uint64
@@ -602,21 +599,6 @@ func updatememstats() {
memstats.heap_objects = memstats.nmalloc - memstats.nfree
}
-// cachestats flushes all mcache stats.
-//
-// The world must be stopped.
-//
-//go:nowritebarrier
-func cachestats() {
- for _, p := range allp {
- c := p.mcache
- if c == nil {
- continue
- }
- purgecachedstats(c)
- }
-}
-
// flushmcache flushes the mcache of allp[i].
//
// The world must be stopped.
@@ -643,13 +625,6 @@ func flushallmcaches() {
}
}
-//go:nosplit
-func purgecachedstats(c *mcache) {
- // Protected by heap lock.
- atomic.Xadd64(&memstats.heap_scan, int64(c.local_scan))
- c.local_scan = 0
-}
-
// Atomically increases a given *system* memory stat. We are counting on this
// stat never overflowing a uintptr, so this function must only be used for
// system memory stats.