]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: track scannable globals space
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 12 Apr 2021 22:40:36 +0000 (22:40 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 29 Oct 2021 18:35:29 +0000 (18:35 +0000)
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>
src/runtime/mgcpacer.go
src/runtime/symtab.go

index 9cc7cf99dbad6495b07afe5d8554ee7d0b0163da..ad7c4bb840dfe15ab76152afa1aaf3cb0bac76f6 100644 (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.
index 41161d6f900561ed420bc85cefbc061d99844fdc..3237a6b708611c222de3d13aa1b427103260051c 100644 (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))
                }
        }