mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: make mheap.pagesInUse an atomic.Uintptr
This change fixes an old TODO that made it a uint64 because it would make alignment within mheap more complicated. Now that we don't have to worry about it since we're using atomic types as much as possible, switch to using a Uintptr. This likely will improve performance a tiny bit on 32-bit platforms, but really it's mostly cleanup. Change-Id: Ie705799a111ccad977fc1f43de8b50cf611be303 Reviewed-on: https://go-review.googlesource.com/c/go/+/429221 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
e28cc362a8
commit
5a37965495
1 changed files with 7 additions and 9 deletions
|
|
@ -100,13 +100,11 @@ type mheap struct {
|
||||||
// accounting for current progress. If we could only adjust
|
// accounting for current progress. If we could only adjust
|
||||||
// the slope, it would create a discontinuity in debt if any
|
// the slope, it would create a discontinuity in debt if any
|
||||||
// progress has already been made.
|
// progress has already been made.
|
||||||
pagesInUse atomic.Uint64 // pages of spans in stats mSpanInUse
|
pagesInUse atomic.Uintptr // pages of spans in stats mSpanInUse
|
||||||
pagesSwept atomic.Uint64 // pages swept this cycle
|
pagesSwept atomic.Uint64 // pages swept this cycle
|
||||||
pagesSweptBasis atomic.Uint64 // pagesSwept to use as the origin of the sweep ratio
|
pagesSweptBasis atomic.Uint64 // pagesSwept to use as the origin of the sweep ratio
|
||||||
sweepHeapLiveBasis uint64 // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without
|
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
|
sweepPagesPerByte float64 // proportional sweep ratio; written with lock, read without
|
||||||
// TODO(austin): pagesInUse should be a uintptr, but the 386
|
|
||||||
// compiler can't 8-byte align fields.
|
|
||||||
|
|
||||||
// Page reclaimer state
|
// Page reclaimer state
|
||||||
|
|
||||||
|
|
@ -1379,7 +1377,7 @@ HaveSpan:
|
||||||
atomic.Or8(&arena.pageInUse[pageIdx], pageMask)
|
atomic.Or8(&arena.pageInUse[pageIdx], pageMask)
|
||||||
|
|
||||||
// Update related page sweeper stats.
|
// Update related page sweeper stats.
|
||||||
h.pagesInUse.Add(int64(npages))
|
h.pagesInUse.Add(npages)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the newly allocated span will be observed
|
// Make sure the newly allocated span will be observed
|
||||||
|
|
@ -1529,7 +1527,7 @@ func (h *mheap) freeSpanLocked(s *mspan, typ spanAllocType) {
|
||||||
print("mheap.freeSpanLocked - span ", s, " ptr ", hex(s.base()), " allocCount ", s.allocCount, " sweepgen ", s.sweepgen, "/", h.sweepgen, "\n")
|
print("mheap.freeSpanLocked - span ", s, " ptr ", hex(s.base()), " allocCount ", s.allocCount, " sweepgen ", s.sweepgen, "/", h.sweepgen, "\n")
|
||||||
throw("mheap.freeSpanLocked - invalid free")
|
throw("mheap.freeSpanLocked - invalid free")
|
||||||
}
|
}
|
||||||
h.pagesInUse.Add(-int64(s.npages))
|
h.pagesInUse.Add(-s.npages)
|
||||||
|
|
||||||
// Clear in-use bit in arena page bitmap.
|
// Clear in-use bit in arena page bitmap.
|
||||||
arena, pageIdx, pageMask := pageIndexOf(s.base())
|
arena, pageIdx, pageMask := pageIndexOf(s.base())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue