diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2019-09-18 15:33:17 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2019-11-08 17:00:57 +0000 |
commit | dac936a4ab8490d90afb9786a69854818f634dc5 (patch) | |
tree | 8dcca475a5a7c52dbd695746b198ca7c11ba1d95 /src/runtime/mgc.go | |
parent | 47232f0d929bd7ca44aeea23ad3f1806dfa55c5e (diff) | |
download | go-git-dac936a4ab8490d90afb9786a69854818f634dc5.tar.gz |
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.go | 3 |
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 { |