aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgclimit.go
diff options
context:
space:
mode:
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>2024-04-14 16:55:57 +0500
committerGopher Robot <gobot@golang.org>2024-04-22 22:07:41 +0000
commit552faa8927a23fd5967435295c14af1741ac3653 (patch)
tree29a005cdc9789cb3bf31a5997511dafab36435b9 /src/runtime/mgclimit.go
parent674657e1304b0ea1815257623150a2e06d8ddac2 (diff)
downloadgo-552faa8927a23fd5967435295c14af1741ac3653.tar.gz
go-552faa8927a23fd5967435295c14af1741ac3653.zip
runtime: reduced struct sizes found via pahole
During my research of pahole with Go structs, I've found couple of structs in runtime/ pkg where we can reduce several structs' sizes highligted by pahole tool which detect byte holes and paddings. Overall, there are 80 bytes reduced. Change-Id: I398e5ed6f5b199394307741981cb5ad5b875e98f Reviewed-on: https://go-review.googlesource.com/c/go/+/578795 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Joedian Reid <joedian@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/mgclimit.go')
-rw-r--r--src/runtime/mgclimit.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/runtime/mgclimit.go b/src/runtime/mgclimit.go
index bd6dc37e04..ad86fbd65b 100644
--- a/src/runtime/mgclimit.go
+++ b/src/runtime/mgclimit.go
@@ -33,16 +33,6 @@ type gcCPULimiterState struct {
lock atomic.Uint32
enabled atomic.Bool
- bucket struct {
- // Invariants:
- // - fill >= 0
- // - capacity >= 0
- // - fill <= capacity
- fill, capacity uint64
- }
- // overflow is the cumulative amount of GC CPU time that we tried to fill the
- // bucket with but exceeded its capacity.
- overflow uint64
// gcEnabled is an internal copy of gcBlackenEnabled that determines
// whether the limiter tracks total assist time.
@@ -55,6 +45,20 @@ type gcCPULimiterState struct {
// the mark and sweep phases.
transitioning bool
+ // test indicates whether this instance of the struct was made for testing purposes.
+ test bool
+
+ bucket struct {
+ // Invariants:
+ // - fill >= 0
+ // - capacity >= 0
+ // - fill <= capacity
+ fill, capacity uint64
+ }
+ // overflow is the cumulative amount of GC CPU time that we tried to fill the
+ // bucket with but exceeded its capacity.
+ overflow uint64
+
// assistTimePool is the accumulated assist time since the last update.
assistTimePool atomic.Int64
@@ -77,9 +81,6 @@ type gcCPULimiterState struct {
//
// gomaxprocs isn't used directly so as to keep this structure unit-testable.
nprocs int32
-
- // test indicates whether this instance of the struct was made for testing purposes.
- test bool
}
// limiting returns true if the CPU limiter is currently enabled, meaning the Go GC