diff options
| author | Michael Pratt <mpratt@google.com> | 2025-06-24 16:33:10 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-06-25 08:55:42 -0700 |
| commit | f069a8299876f9987a01a8d4a664d2a887bd5efc (patch) | |
| tree | 1a56597b61517b2c6695ca37b7ad67019356aadc /src/runtime/testdata/testprog/gomaxprocs.go | |
| parent | e515ef8bc271f632bb2ebb94e8e700ab67274268 (diff) | |
| download | go-f069a8299876f9987a01a8d4a664d2a887bd5efc.tar.xz | |
runtime: note custom GOMAXPROCS even if value doesn't change
When an application calls runtime.GOMAXPROCS(runtime.GOMAXPROCS(0)), the
runtime does not need to change the actual GOMAXPROCS value (via STW).
However, this call must still transition from "automatic" to "custom"
GOMAXPROCS state, thus disabling background updates.
Thus this case shouldn't return quite as early as it currently does.
Change-Id: I6a6a636c42f73996532bd9f7beb95e933256c9e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/683815
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/testdata/testprog/gomaxprocs.go')
| -rw-r--r-- | src/runtime/testdata/testprog/gomaxprocs.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/gomaxprocs.go b/src/runtime/testdata/testprog/gomaxprocs.go index 915e3c4dad..99bc9f1dbb 100644 --- a/src/runtime/testdata/testprog/gomaxprocs.go +++ b/src/runtime/testdata/testprog/gomaxprocs.go @@ -133,6 +133,20 @@ func UpdateGOMAXPROCS() { mustSetCPUMax(path, 200000) mustNotChangeMaxProcs(3) + // Re-enable updates. Change is immediately visible. + runtime.SetDefaultGOMAXPROCS() + procs = runtime.GOMAXPROCS(0) + println("GOMAXPROCS:", procs) + if procs != 2 { + panic(fmt.Sprintf("GOMAXPROCS got %d want %d", procs, 2)) + } + + // Setting GOMAXPROCS to itself also disables updates, despite not + // changing the value itself. + runtime.GOMAXPROCS(runtime.GOMAXPROCS(0)) + mustSetCPUMax(path, 300000) + mustNotChangeMaxProcs(2) + println("OK") } |
