Skip to content

Commit 9da6415

Browse files
committed
runtime: track scannable globals space
For #44167. Change-Id: I2cd13229d88f630451fabd113b0e5a04841e9e79 Reviewed-on: https://go-review.googlesource.com/c/go/+/309590 Trust: Michael Knyszek <[email protected]> Run-TryBot: Michael Knyszek <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 9ac1ee2 commit 9da6415

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/runtime/mgcpacer.go

+10
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ type gcControllerState struct {
182182
// Read and updated atomically.
183183
scannableStackSize uint64
184184

185+
// globalsScan is the total amount of global variable space
186+
// that is scannable.
187+
//
188+
// Read and updated atomically.
189+
globalsScan uint64
190+
185191
// heapMarked is the number of bytes marked by the previous
186192
// GC. After mark termination, heapLive == heapMarked, but
187193
// unlike heapLive, heapMarked does not change until the
@@ -715,6 +721,10 @@ func (c *gcControllerState) addScannableStack(pp *p, amount int64) {
715721
}
716722
}
717723

724+
func (c *gcControllerState) addGlobals(amount int64) {
725+
atomic.Xadd64(&c.globalsScan, amount)
726+
}
727+
718728
// commit sets the trigger ratio and updates everything
719729
// derived from it: the absolute trigger, the heap goal, mark pacing,
720730
// and sweep pacing.

src/runtime/symtab.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,11 @@ func modulesinit() {
529529
}
530530
*modules = append(*modules, md)
531531
if md.gcdatamask == (bitvector{}) {
532-
md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), md.edata-md.data)
533-
md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), md.ebss-md.bss)
532+
scanDataSize := md.edata - md.data
533+
md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), scanDataSize)
534+
scanBSSSize := md.ebss - md.bss
535+
md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), scanBSSSize)
536+
gcController.addGlobals(int64(scanDataSize + scanBSSSize))
534537
}
535538
}
536539

0 commit comments

Comments
 (0)