aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgc.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-09-18 15:33:17 +0000
committerMichael Knyszek <mknyszek@google.com>2019-11-08 17:00:57 +0000
commitdac936a4ab8490d90afb9786a69854818f634dc5 (patch)
tree8dcca475a5a7c52dbd695746b198ca7c11ba1d95 /src/runtime/mgc.go
parent47232f0d929bd7ca44aeea23ad3f1806dfa55c5e (diff)
downloadgo-dac936a4ab8490d90afb9786a69854818f634dc5.tar.gz
go-dac936a4ab8490d90afb9786a69854818f634dc5.zip
runtime: make more page sweeper operations atomic
This change makes it so that allocation and free related page sweeper metadata operations (e.g. pageInUse and pagesInUse) are atomic rather than protected by the heap lock. This will help in reducing the length of the critical path with the heap lock held in future changes. Updates #35112. Change-Id: Ie82bff024204dd17c4c671af63350a7a41add354 Reviewed-on: https://go-review.googlesource.com/c/go/+/196640 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/mgc.go')
-rw-r--r--src/runtime/mgc.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 0666099e02..0bc5568442 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -865,7 +865,8 @@ func gcSetTriggerRatio(triggerRatio float64) {
heapDistance = _PageSize
}
pagesSwept := atomic.Load64(&mheap_.pagesSwept)
- sweepDistancePages := int64(mheap_.pagesInUse) - int64(pagesSwept)
+ pagesInUse := atomic.Load64(&mheap_.pagesInUse)
+ sweepDistancePages := int64(pagesInUse) - int64(pagesSwept)
if sweepDistancePages <= 0 {
mheap_.sweepPagesPerByte = 0
} else {