]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/runtime2: pack the sudog struct
authorAaron Patterson <tenderlove@ruby-lang.org>
Tue, 14 Jan 2020 19:13:47 +0000 (19:13 +0000)
committerKeith Randall <khr@golang.org>
Thu, 7 May 2020 04:05:18 +0000 (04:05 +0000)
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: d63b4e086b17da74e185046dfecb12d58e4f19ac
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>
src/runtime/export_test.go
src/runtime/runtime2.go
src/runtime/sizeof_test.go

index 4c1150acd4aac05b097086898a3565157cc7c80f..f2461f0cb01bf86cf04c19cb7720be7aee878bbf 100644 (file)
@@ -483,6 +483,8 @@ func GetNextArenaHint() uintptr {
 
 type G = g
 
+type Sudog = sudog
+
 func Getg() *G {
        return getg()
 }
index 2c566b5424b51dca9f5952dd89252b620c70a214..1fe41cf5b290cf861f40eb71c244cee81bf91579 100644 (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
index 852244d4252eb01f6a54d1915aa59c438b809cb2..d6156902c187fbe525380651a7e39ea074220ca1 100644 (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 {