1
0
mirror of https://github.com/golang/go synced 2024-11-24 06:30:22 -07:00

runtime: track scannable globals space

For #44167.

Change-Id: I2cd13229d88f630451fabd113b0e5a04841e9e79
Reviewed-on: https://go-review.googlesource.com/c/go/+/309590
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Anthony Knyszek 2021-04-12 22:40:36 +00:00 committed by Michael Knyszek
parent 9ac1ee2d46
commit 9da64156a6
2 changed files with 15 additions and 2 deletions

View File

@ -182,6 +182,12 @@ type gcControllerState struct {
// Read and updated atomically.
scannableStackSize uint64
// globalsScan is the total amount of global variable space
// that is scannable.
//
// Read and updated atomically.
globalsScan uint64
// heapMarked is the number of bytes marked by the previous
// GC. After mark termination, heapLive == heapMarked, but
// unlike heapLive, heapMarked does not change until the
@ -715,6 +721,10 @@ func (c *gcControllerState) addScannableStack(pp *p, amount int64) {
}
}
func (c *gcControllerState) addGlobals(amount int64) {
atomic.Xadd64(&c.globalsScan, amount)
}
// commit sets the trigger ratio and updates everything
// derived from it: the absolute trigger, the heap goal, mark pacing,
// and sweep pacing.

View File

@ -529,8 +529,11 @@ func modulesinit() {
}
*modules = append(*modules, md)
if md.gcdatamask == (bitvector{}) {
md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), md.edata-md.data)
md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), md.ebss-md.bss)
scanDataSize := md.edata - md.data
md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), scanDataSize)
scanBSSSize := md.ebss - md.bss
md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), scanBSSSize)
gcController.addGlobals(int64(scanDataSize + scanBSSSize))
}
}