]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: break out new minimum heap size into a goexperiment
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 1 Dec 2021 15:26:31 +0000 (15:26 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 2 Dec 2021 18:02:46 +0000 (18:02 +0000)
The new minimum heap of 512 KiB has been the cause of some build
slowdown (~1%) and microbenchmark slowdown (usually ~0%, up to ~50%)
because of two reasons:
1. Applications with lots of small short-lived processes execute many
   more GC cycles.
2. Applications with heaps <4 MiB GC up to 8x more often.

In many ways these consequences are inevitable given how GOGC works,
however we need to investigate more as to whether the apparent slowdowns
are indeed unavoidable or if the GC has issues scaling down, which it's
too late for for this release.

Given that this release is already huge, it's OK to push this back.
We'll take a closer look at it next cycle, so place block it behind a
new goexperiment to allow users and ourselves to easily experiment with
it.

Fixes #49744.
Updates #44167.

Change-Id: Ibad51f7873de7517490c89802f3c593834e77ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/368137
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/internal/goexperiment/exp_heapminimum512kib_off.go [new file with mode: 0644]
src/internal/goexperiment/exp_heapminimum512kib_on.go [new file with mode: 0644]
src/internal/goexperiment/flags.go
src/runtime/mgcpacer.go

diff --git a/src/internal/goexperiment/exp_heapminimum512kib_off.go b/src/internal/goexperiment/exp_heapminimum512kib_off.go
new file mode 100644 (file)
index 0000000..09da431
--- /dev/null
@@ -0,0 +1,9 @@
+// Code generated by mkconsts.go. DO NOT EDIT.
+
+//go:build !goexperiment.heapminimum512kib
+// +build !goexperiment.heapminimum512kib
+
+package goexperiment
+
+const HeapMinimum512KiB = false
+const HeapMinimum512KiBInt = 0
diff --git a/src/internal/goexperiment/exp_heapminimum512kib_on.go b/src/internal/goexperiment/exp_heapminimum512kib_on.go
new file mode 100644 (file)
index 0000000..bab684b
--- /dev/null
@@ -0,0 +1,9 @@
+// Code generated by mkconsts.go. DO NOT EDIT.
+
+//go:build goexperiment.heapminimum512kib
+// +build goexperiment.heapminimum512kib
+
+package goexperiment
+
+const HeapMinimum512KiB = true
+const HeapMinimum512KiBInt = 1
index 3bf19222e1cb02f04f6b2d239735f169205f5dc5..6d935edc2b223564805b8e8081978391cc42c45d 100644 (file)
@@ -89,4 +89,11 @@ type Flags struct {
        // Details regarding the new pacer may be found at
        // https://golang.org/design/44167-gc-pacer-redesign
        PacerRedesign bool
+
+       // HeapMinimum512KiB reduces the minimum heap size to 512 KiB.
+       //
+       // This was originally reduced as part of PacerRedesign, but
+       // has been broken out to its own experiment that is disabled
+       // by default.
+       HeapMinimum512KiB bool
 }
index 868666036c380975eb351dbc43490e17e4f07c9d..6df8af45a8b71234db3b59ad25fa81e59ba0ddcb 100644 (file)
@@ -53,8 +53,8 @@ const (
        gcOverAssistWork = 64 << 10
 
        // defaultHeapMinimum is the value of heapMinimum for GOGC==100.
-       defaultHeapMinimum = goexperiment.PacerRedesignInt*(512<<10) +
-               (1-goexperiment.PacerRedesignInt)*(4<<20)
+       defaultHeapMinimum = (goexperiment.HeapMinimum512KiBInt)*(512<<10) +
+               (1-goexperiment.HeapMinimum512KiBInt)*(4<<20)
 
        // scannableStackSizeSlack is the bytes of stack space allocated or freed
        // that can accumulate on a P before updating gcController.stackSize.