diff options
author | Rick Hudson <rlh@golang.org> | 2016-02-11 13:57:58 -0500 |
---|---|---|
committer | Rick Hudson <rlh@golang.org> | 2016-04-27 21:54:47 +0000 |
commit | 3479b065d43f2990ac12e7b00ddff6f63a876ca9 (patch) | |
tree | 491ad3b3ea77e4e4a9202ebaaa933296206007da /src/runtime/mcache.go | |
parent | dc65a82eff0a3af5a26f6c6d31c53bdac9b31168 (diff) | |
download | go-3479b065d43f2990ac12e7b00ddff6f63a876ca9.tar.gz go-3479b065d43f2990ac12e7b00ddff6f63a876ca9.zip |
[dev.garbage] runtime: allocate directly from GC mark bits
Instead of building a freelist from the mark bits generated
by the GC this CL allocates directly from the mark bits.
The approach moves the mark bits from the pointer/no pointer
heap structures into their own per span data structures. The
mark/allocation vectors consist of a single mark bit per
object. Two vectors are maintained, one for allocation and
one for the GC's mark phase. During the GC cycle's sweep
phase the interpretation of the vectors is swapped. The
mark vector becomes the allocation vector and the old
allocation vector is cleared and becomes the mark vector that
the next GC cycle will use.
Marked entries in the allocation vector indicate that the
object is not free. Each allocation vector maintains a boundary
between areas of the span already allocated from and areas
not yet allocated from. As objects are allocated this boundary
is moved until it reaches the end of the span. At this point
further allocations will be done from another span.
Since we no longer sweep a span inspecting each freed object
the responsibility for maintaining pointer/scalar bits in
the heapBitMap containing is now the responsibility of the
the routines doing the actual allocation.
This CL is functionally complete and ready for performance
tuning.
Change-Id: I336e0fc21eef1066e0b68c7067cc71b9f3d50e04
Reviewed-on: https://go-review.googlesource.com/19470
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/mcache.go')
-rw-r--r-- | src/runtime/mcache.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go index 2230c5c200..424fa0efac 100644 --- a/src/runtime/mcache.go +++ b/src/runtime/mcache.go @@ -108,9 +108,11 @@ func (c *mcache) refill(sizeclass int32) *mspan { _g_.m.locks++ // Return the current cached span to the central lists. s := c.alloc[sizeclass] - if s.freelist.ptr() != nil { - throw("refill on a nonempty span") + + if uintptr(s.ref) != s.nelems { + throw("refill of span with free space remaining") } + if s != &emptymspan { s.incache = false } @@ -120,10 +122,11 @@ func (c *mcache) refill(sizeclass int32) *mspan { if s == nil { throw("out of memory") } - if s.freelist.ptr() == nil { - println(s.ref, (s.npages<<_PageShift)/s.elemsize) - throw("empty span") + + if uintptr(s.ref) == s.nelems { + throw("span has no free space") } + c.alloc[sizeclass] = s _g_.m.locks-- return s |