Skip to content

Commit 94c4cdc

Browse files
rhyshgopherbot
authored andcommitted
runtime: remove GODEBUG=runtimecontentionstacks
Go 1.22 promised to remove the setting in a future release once the semantics of runtime-internal lock contention matched that of sync.Mutex. That work is done, remove the setting. Previously reviewed as https://go.dev/cl/585639. For #66999 Change-Id: I9fe62558ba0ac12824874a0bb1b41efeb7c0853f Reviewed-on: https://go-review.googlesource.com/c/go/+/668995 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Rhys Hiltner <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 591c4b5 commit 94c4cdc

File tree

7 files changed

+13
-38
lines changed

7 files changed

+13
-38
lines changed

doc/godebug.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ Go command will follow symlinks to regular files embedding files.
169169
The default value `embedfollowsymlinks=0` does not allow following
170170
symlinks. `embedfollowsymlinks=1` will allow following symlinks.
171171

172+
Go 1.25 corrected the semantics of contention reports for runtime-internal locks,
173+
and so removed the [`runtimecontentionstacks` setting](/pkg/runtime#hdr-Environment_Variable).
174+
172175
### Go 1.24
173176

174177
Go 1.24 added a new `fips140` setting that controls whether the Go
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The mutex profile for contention on runtime-internal locks now correctly points
2+
to the end of the critical section that caused the delay. This matches the
3+
profile's behavior for contention on `sync.Mutex` values. The
4+
`runtimecontentionstacks` setting for `GODEBUG`, which allowed opting in to the
5+
unusual behavior of Go 1.22 through 1.24 for this part of the profile, is now
6+
gone.

src/runtime/extern.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,6 @@ It is a comma-separated list of name=val pairs setting these named variables:
166166
panicnil: setting panicnil=1 disables the runtime error when calling panic with nil
167167
interface value or an untyped nil.
168168
169-
runtimecontentionstacks: setting runtimecontentionstacks=1 enables inclusion of call stacks
170-
related to contention on runtime-internal locks in the "mutex" profile, subject to the
171-
MutexProfileFraction setting. When runtimecontentionstacks=0, contention on
172-
runtime-internal locks will report as "runtime._LostContendedRuntimeLock". When
173-
runtimecontentionstacks=1, the call stacks will correspond to the unlock call that released
174-
the lock. But instead of the value corresponding to the amount of contention that call
175-
stack caused, it corresponds to the amount of time the caller of unlock had to wait in its
176-
original call to lock. A future release is expected to align those and remove this setting.
177-
178169
invalidptr: invalidptr=1 (the default) causes the garbage collector and stack
179170
copier to crash the program if an invalid pointer value (for example, 1)
180171
is found in a pointer-typed location. Setting invalidptr=0 disables this check.

src/runtime/metrics_test.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package runtime_test
66

77
import (
88
"bytes"
9-
"fmt"
109
"internal/abi"
1110
"internal/goexperiment"
1211
"internal/profile"
@@ -955,17 +954,6 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) {
955954
t.Fatalf("need MutexProfileRate 0, got %d", old)
956955
}
957956

958-
{
959-
before := os.Getenv("GODEBUG")
960-
for _, s := range strings.Split(before, ",") {
961-
if strings.HasPrefix(s, "runtimecontentionstacks=") {
962-
t.Logf("GODEBUG includes explicit setting %q", s)
963-
}
964-
}
965-
defer func() { os.Setenv("GODEBUG", before) }()
966-
os.Setenv("GODEBUG", fmt.Sprintf("%s,runtimecontentionstacks=1", before))
967-
}
968-
969957
t.Logf("NumCPU %d", runtime.NumCPU())
970958
t.Logf("GOMAXPROCS %d", runtime.GOMAXPROCS(0))
971959
if minCPU := 2; runtime.NumCPU() < minCPU {
@@ -1229,9 +1217,9 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) {
12291217

12301218
stks[i] = []string{
12311219
"runtime.unlock",
1232-
"runtime_test." + name + ".func5.1.1",
1220+
"runtime_test." + name + ".func4.1.1",
12331221
marker,
1234-
"runtime_test." + name + ".func5.1",
1222+
"runtime_test." + name + ".func4.1",
12351223
"runtime_test.(*contentionWorker).run",
12361224
}
12371225
}
@@ -1411,14 +1399,14 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) {
14111399
{
14121400
"runtime.unlock",
14131401
"runtime.semrelease1",
1414-
"runtime_test.TestRuntimeLockMetricsAndProfile.func6.1",
1402+
"runtime_test.TestRuntimeLockMetricsAndProfile.func5.1",
14151403
"runtime_test.(*contentionWorker).run",
14161404
},
14171405
{
14181406
"runtime.unlock",
14191407
"runtime.semacquire1",
14201408
"runtime.semacquire",
1421-
"runtime_test.TestRuntimeLockMetricsAndProfile.func6.1",
1409+
"runtime_test.TestRuntimeLockMetricsAndProfile.func5.1",
14221410
"runtime_test.(*contentionWorker).run",
14231411
},
14241412
}

src/runtime/mprof.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,6 @@ func (prof *mLockProfile) captureStack() {
732732
prof.haveStack = true
733733

734734
prof.stack[0] = logicalStackSentinel
735-
if debug.runtimeContentionStacks.Load() == 0 {
736-
prof.stack[1] = abi.FuncPCABIInternal(_LostContendedRuntimeLock) + sys.PCQuantum
737-
prof.stack[2] = 0
738-
return
739-
}
740735

741736
var nstk int
742737
gp := getg()

src/runtime/pprof/pprof.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ import (
169169
// holds a lock for 1s while 5 other goroutines are waiting for the entire
170170
// second to acquire the lock, its unlock call stack will report 5s of
171171
// contention.
172-
//
173-
// Runtime-internal locks are always reported at the location
174-
// "runtime._LostContendedRuntimeLock". More detailed stack traces for
175-
// runtime-internal locks can be obtained by setting
176-
// `GODEBUG=runtimecontentionstacks=1` (see package [runtime] docs for
177-
// caveats).
178172
type Profile struct {
179173
name string
180174
mu sync.Mutex

src/runtime/runtime1.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ var debug struct {
320320
gctrace int32
321321
invalidptr int32
322322
madvdontneed int32 // for Linux; issue 28466
323-
runtimeContentionStacks atomic.Int32
324323
scavtrace int32
325324
scheddetail int32
326325
schedtrace int32
@@ -385,7 +384,6 @@ var dbgvars = []*dbgVar{
385384
{name: "madvdontneed", value: &debug.madvdontneed},
386385
{name: "panicnil", atomic: &debug.panicnil},
387386
{name: "profstackdepth", value: &debug.profstackdepth, def: 128},
388-
{name: "runtimecontentionstacks", atomic: &debug.runtimeContentionStacks},
389387
{name: "sbrk", value: &debug.sbrk},
390388
{name: "scavtrace", value: &debug.scavtrace},
391389
{name: "scheddetail", value: &debug.scheddetail},

0 commit comments

Comments
 (0)