1
0
mirror of https://github.com/golang/go synced 2024-11-12 00:30:22 -07:00

runtime/runtime2: pack the sudog struct

This commit moves the isSelect bool below the ticket uint32.  The
boolean was consuming 8 bytes of the struct.  The uint32 was also
consuming 8 bytes, so we can pack isSelect below the uint32 and save 8
bytes.  This reduces the sudog struct from 96 bytes to 88 bytes.

Change-Id: If555cdaf2f5eaa125e2590fc4d113dbc99750738
GitHub-Last-Rev: d63b4e086b
GitHub-Pull-Request: golang/go#36552
Reviewed-on: https://go-review.googlesource.com/c/go/+/214677
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Aaron Patterson 2020-01-14 19:13:47 +00:00 committed by Keith Randall
parent 5d9549debb
commit 94e61ab94d
3 changed files with 8 additions and 3 deletions

View File

@ -483,6 +483,8 @@ func GetNextArenaHint() uintptr {
type G = g
type Sudog = sudog
func Getg() *G {
return getg()
}

View File

@ -349,9 +349,6 @@ type sudog struct {
g *g
// isSelect indicates g is participating in a select, so
// g.selectDone must be CAS'd to win the wake-up race.
isSelect bool
next *sudog
prev *sudog
elem unsafe.Pointer // data element (may point to stack)
@ -364,6 +361,11 @@ type sudog struct {
acquiretime int64
releasetime int64
ticket uint32
// isSelect indicates g is participating in a select, so
// g.selectDone must be CAS'd to win the wake-up race.
isSelect bool
parent *sudog // semaRoot binary tree
waitlink *sudog // g.waiting list or semaRoot
waittail *sudog // semaRoot

View File

@ -22,6 +22,7 @@ func TestSizeof(t *testing.T) {
_64bit uintptr // size on 64bit platforms
}{
{runtime.G{}, 216, 376}, // g, but exported for testing
{runtime.Sudog{}, 56, 88}, // sudog, but exported for testing
}
for _, tt := range tests {