Skip to content

Commit 198440c

Browse files
committed
runtime: remove GODEBUG=gcrescanstacks=1 mode
Currently, setting GODEBUG=gcrescanstacks=1 enables a debugging mode where the garbage collector re-scans goroutine stacks during mark termination. This was introduced in Go 1.8 to debug the hybrid write barrier, but I don't think we ever used it. Now it's one of the last sources of mark work during mark termination. This CL removes it. Updates #26903. This is preparation for unifying STW GC and concurrent GC. Updates #17503. Change-Id: I6ae04d3738aa9c448e6e206e21857a33ecd12acf Reviewed-on: https://go-review.googlesource.com/c/134777 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
1 parent ecc3659 commit 198440c

File tree

4 files changed

+5
-26
lines changed

4 files changed

+5
-26
lines changed

src/runtime/extern.go

-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ It is a comma-separated list of name=val pairs setting these named variables:
5050
gcshrinkstackoff: setting gcshrinkstackoff=1 disables moving goroutines
5151
onto smaller stacks. In this mode, a goroutine's stack can only grow.
5252
53-
gcrescanstacks: setting gcrescanstacks=1 enables stack
54-
re-scanning during the STW mark termination phase. This is
55-
helpful for debugging if objects are being prematurely
56-
garbage collected.
57-
5853
gcstoptheworld: setting gcstoptheworld=1 disables concurrent garbage collection,
5954
making every garbage collection a stop-the-world event. Setting gcstoptheworld=2
6055
also disables concurrent sweeping after the garbage collection finishes.

src/runtime/mgc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ func gcMark(start_time int64) {
19141914
//
19151915
// TODO(austin): Move STW marking out of
19161916
// mark termination and eliminate this code path.
1917-
if debug.gcstoptheworld == 0 && debug.gcrescanstacks == 0 {
1917+
if debug.gcstoptheworld == 0 {
19181918
print("runtime: full=", hex(work.full), " nDataRoots=", work.nDataRoots, " nBSSRoots=", work.nBSSRoots, " nSpanRoots=", work.nSpanRoots, " nStackRoots=", work.nStackRoots, "\n")
19191919
panic("non-empty mark queue after concurrent mark")
19201920
}

src/runtime/mgcmark.go

+4-18
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ func gcMarkRootPrepare() {
116116
// contain pointers to unmarked objects, so on the
117117
// second markroot, there's no need to scan stacks.
118118
work.nStackRoots = 0
119-
120-
if debug.gcrescanstacks > 0 {
121-
// Scan stacks anyway for debugging.
122-
work.nStackRoots = int(atomic.Loaduintptr(&allglen))
123-
}
124119
}
125120

126121
work.markrootNext = 0
@@ -138,19 +133,10 @@ func gcMarkRootCheck() {
138133
lock(&allglock)
139134
// Check that stacks have been scanned.
140135
var gp *g
141-
if gcphase == _GCmarktermination && debug.gcrescanstacks > 0 {
142-
for i := 0; i < len(allgs); i++ {
143-
gp = allgs[i]
144-
if !(gp.gcscandone && gp.gcscanvalid) && readgstatus(gp) != _Gdead {
145-
goto fail
146-
}
147-
}
148-
} else {
149-
for i := 0; i < work.nStackRoots; i++ {
150-
gp = allgs[i]
151-
if !gp.gcscandone {
152-
goto fail
153-
}
136+
for i := 0; i < work.nStackRoots; i++ {
137+
gp = allgs[i]
138+
if !gp.gcscandone {
139+
goto fail
154140
}
155141
}
156142
unlock(&allglock)

src/runtime/runtime1.go

-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ var debug struct {
305305
gccheckmark int32
306306
gcpacertrace int32
307307
gcshrinkstackoff int32
308-
gcrescanstacks int32
309308
gcstoptheworld int32
310309
gctrace int32
311310
invalidptr int32
@@ -323,7 +322,6 @@ var dbgvars = []dbgVar{
323322
{"gccheckmark", &debug.gccheckmark},
324323
{"gcpacertrace", &debug.gcpacertrace},
325324
{"gcshrinkstackoff", &debug.gcshrinkstackoff},
326-
{"gcrescanstacks", &debug.gcrescanstacks},
327325
{"gcstoptheworld", &debug.gcstoptheworld},
328326
{"gctrace", &debug.gctrace},
329327
{"invalidptr", &debug.invalidptr},

0 commit comments

Comments
 (0)