]> Cypherpunks repositories - gostls13.git/commit
runtime: split object finding out of heapBitsForObject
authorAustin Clements <austin@google.com>
Tue, 12 Dec 2017 00:40:12 +0000 (19:40 -0500)
committerAustin Clements <austin@google.com>
Thu, 15 Feb 2018 21:12:13 +0000 (21:12 +0000)
commit058bb7ea278d8e073be1e1c73d01fbfd74c170fd
treee7f5969e7269be71bb20b3e9837bad1128de597a
parent41e6abdc61dd23ede4d3509aebf7b5a638f53712
runtime: split object finding out of heapBitsForObject

heapBitsForObject does two things: it finds the base of the object and
it creates the heapBits for the base of the object. There are several
places where we just care about the base of the object. Furthermore,
greyobject only needs the heapBits in the checkmark path and can
easily compute them only when needed. Once we eliminate passing the
heap bits to grayobject, almost all uses of heapBitsForObject don't
need the heap bits.

Hence, this splits heapBitsForObject into findObject and
heapBitsForAddr (the latter already exists), removes the hbits
argument to grayobject, and replaces all heapBitsForObject calls with
calls to findObject.

In addition to making things cleaner overall, heapBitsForAddr is going
to get more expensive shortly, so it's important that we don't do it
needlessly.

Note that there's an interesting performance pitfall here. I had
originally moved findObject to mheap.go, since it made more sense
there. However, that leads to a ~2% slow down and a whopping 11%
increase in L1 icache misses on both the x/garbage and compilebench
benchmarks. This suggests we may want to be more principled about
this, but, for now, let's just leave findObject in mbitmap.go.

(I tried to make findObject small enough to inline by splitting out
the error case, but, sadly, wasn't quite able to get it under the
inlining budget.)

Change-Id: I7bcb92f383ade565d22a9f2494e4c66fd513fb10
Reviewed-on: https://go-review.googlesource.com/85878
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/cgocall.go
src/runtime/mbitmap.go
src/runtime/mfinal.go
src/runtime/mgcmark.go
src/runtime/mheap.go
src/runtime/mwbbuf.go
src/runtime/race.go