// Avoid setting the sweep ratio extremely high
heapDistance = _PageSize
}
- pagesSwept := atomic.Load64(&mheap_.pagesSwept)
+ pagesSwept := mheap_.pagesSwept.Load()
pagesInUse := mheap_.pagesInUse.Load()
sweepDistancePages := int64(pagesInUse) - int64(pagesSwept)
if sweepDistancePages <= 0 {
func (l *sweepLocker) sweepIsDone() {
if debug.gcpacertrace > 0 {
- print("pacer: sweep done at heap size ", gcController.heapLive>>20, "MB; allocated ", (gcController.heapLive-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept, " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n")
+ print("pacer: sweep done at heap size ", gcController.heapLive>>20, "MB; allocated ", (gcController.heapLive-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept.Load(), " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n")
}
}
traceGCSweepSpan(s.npages * _PageSize)
}
- atomic.Xadd64(&mheap_.pagesSwept, int64(s.npages))
+ mheap_.pagesSwept.Add(int64(s.npages))
spc := s.spanclass
size := s.elemsize
// Fix debt if necessary.
newHeapLive := uintptr(atomic.Load64(&gcController.heapLive)-mheap_.sweepHeapLiveBasis) + spanBytes
pagesTarget := int64(mheap_.sweepPagesPerByte*float64(newHeapLive)) - int64(callerSweepPages)
- for pagesTarget > int64(atomic.Load64(&mheap_.pagesSwept)-sweptBasis) {
+ for pagesTarget > int64(mheap_.pagesSwept.Load()-sweptBasis) {
if sweepone() == ^uintptr(0) {
mheap_.sweepPagesPerByte = 0
break
// the slope, it would create a discontinuity in debt if any
// progress has already been made.
pagesInUse atomic.Uint64 // pages of spans in stats mSpanInUse
- pagesSwept uint64 // pages swept this cycle; updated atomically
+ pagesSwept atomic.Uint64 // pages swept this cycle
pagesSweptBasis uint64 // pagesSwept to use as the origin of the sweep ratio; updated atomically
sweepHeapLiveBasis uint64 // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without
sweepPagesPerByte float64 // proportional sweep ratio; written with lock, read without