Skip to content

Commit

Permalink
runtime: track scannable globals space
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mknyszek committed Oct 29, 2021
1 parent 9ac1ee2 commit 9da6415
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/runtime/mgcpacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions src/runtime/symtab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 9da6415

Please sign in to comment.