Skip to content

Commit 87e930f

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. For #66999 Change-Id: I3c4894148385adf2756d8754e44d7317305ad758 Reviewed-on: https://go-review.googlesource.com/c/go/+/585639 Reviewed-by: Carlos Amedee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Rhys Hiltner <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent ba1c5b2 commit 87e930f

File tree

7 files changed

+11
-37
lines changed

7 files changed

+11
-37
lines changed

doc/godebug.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ This behavior is controlled by the `winreadlinkvolume` setting.
176176
For Go 1.23, it defaults to `winreadlinkvolume=1`.
177177
Previous versions default to `winreadlinkvolume=0`.
178178

179+
Go 1.23 corrected the semantics of contention reports for runtime-internal locks,
180+
and so removed the [`runtimecontentionstacks` setting](/pkg/runtime#hdr-Environment_Variable).
181+
179182
### Go 1.22
180183

181184
Go 1.22 adds a configurable limit to control the maximum acceptable RSA key size
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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 Go
5+
1.22's unusual behavior for this part of the profile, is now gone.

src/runtime/extern.go

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

src/runtime/metrics_test.go

Lines changed: 3 additions & 15 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 {
@@ -1157,7 +1145,7 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) {
11571145

11581146
stks := [][]string{{
11591147
"runtime.unlock",
1160-
"runtime_test." + name + ".func5.1",
1148+
"runtime_test." + name + ".func4.1",
11611149
"runtime_test.(*contentionWorker).run",
11621150
}}
11631151

@@ -1257,14 +1245,14 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) {
12571245
{
12581246
"runtime.unlock",
12591247
"runtime.semrelease1",
1260-
"runtime_test.TestRuntimeLockMetricsAndProfile.func6.1",
1248+
"runtime_test.TestRuntimeLockMetricsAndProfile.func5.1",
12611249
"runtime_test.(*contentionWorker).run",
12621250
},
12631251
{
12641252
"runtime.unlock",
12651253
"runtime.semacquire1",
12661254
"runtime.semacquire",
1267-
"runtime_test.TestRuntimeLockMetricsAndProfile.func6.1",
1255+
"runtime_test.TestRuntimeLockMetricsAndProfile.func5.1",
12681256
"runtime_test.(*contentionWorker).run",
12691257
},
12701258
}

src/runtime/mprof.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,6 @@ func (prof *mLockProfile) captureStack() {
915915
}
916916

917917
prof.stack[0] = logicalStackSentinel
918-
if debug.runtimeContentionStacks.Load() == 0 {
919-
prof.stack[1] = abi.FuncPCABIInternal(_LostContendedRuntimeLock) + sys.PCQuantum
920-
prof.stack[2] = 0
921-
return
922-
}
923918

924919
var nstk int
925920
gp := getg()

src/runtime/pprof/pprof.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,6 @@ import (
164164
// holds a lock for 1s while 5 other goroutines are waiting for the entire
165165
// second to acquire the lock, its unlock call stack will report 5s of
166166
// contention.
167-
//
168-
// Runtime-internal locks are always reported at the location
169-
// "runtime._LostContendedRuntimeLock". More detailed stack traces for
170-
// runtime-internal locks can be obtained by setting
171-
// `GODEBUG=runtimecontentionstacks=1` (see package [runtime] docs for
172-
// caveats).
173167
type Profile struct {
174168
name string
175169
mu sync.Mutex

src/runtime/runtime1.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ var debug struct {
319319
gctrace int32
320320
invalidptr int32
321321
madvdontneed int32 // for Linux; issue 28466
322-
runtimeContentionStacks atomic.Int32
323322
scavtrace int32
324323
scheddetail int32
325324
schedtrace int32
@@ -381,7 +380,6 @@ var dbgvars = []*dbgVar{
381380
{name: "madvdontneed", value: &debug.madvdontneed},
382381
{name: "panicnil", atomic: &debug.panicnil},
383382
{name: "profstackdepth", value: &debug.profstackdepth, def: 128},
384-
{name: "runtimecontentionstacks", atomic: &debug.runtimeContentionStacks},
385383
{name: "sbrk", value: &debug.sbrk},
386384
{name: "scavtrace", value: &debug.scavtrace},
387385
{name: "scheddetail", value: &debug.scheddetail},

0 commit comments

Comments
 (0)