From 74993bffe1a5c7e28f43423f9925bf9f6ec17aad Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 21 Nov 2023 16:59:44 +0000 Subject: [PATCH] runtime: disable trace v2 optimistic deadlock debugger The v2 execution tracer has a rudimentary deadlock detector, but it's based on an arbitrary threshold that an actually get hit even if there's no deadlock. This ends up breaking tests sometimes, and it would be bad if this just appeared in production logs. Put this 'deadlock detector' behind a flag. For #55317. Change-Id: I286f0c05b3ac9600f4f2f9696065cac8bbd25f00 Reviewed-on: https://go-review.googlesource.com/c/go/+/544235 Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI --- src/runtime/trace2.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/runtime/trace2.go b/src/runtime/trace2.go index 1a58015989..59ea190089 100644 --- a/src/runtime/trace2.go +++ b/src/runtime/trace2.go @@ -443,6 +443,7 @@ func traceAdvance(stopTrace bool) { // held, we can be certain that when there are no writers there are // also no stale generation values left. Therefore, it's safe to flush // any buffers that remain in that generation's slot. + const debugDeadlock = false systemstack(func() { // Track iterations for some rudimentary deadlock detection. i := 0 @@ -479,16 +480,18 @@ func traceAdvance(stopTrace bool) { osyield() } - // Try to detect a deadlock. We probably shouldn't loop here - // this many times. - if i > 100000 && !detectedDeadlock { - detectedDeadlock = true - println("runtime: failing to flush") - for mp := mToFlush; mp != nil; mp = mp.trace.link { - print("runtime: m=", mp.id, "\n") + if debugDeadlock { + // Try to detect a deadlock. We probably shouldn't loop here + // this many times. + if i > 100000 && !detectedDeadlock { + detectedDeadlock = true + println("runtime: failing to flush") + for mp := mToFlush; mp != nil; mp = mp.trace.link { + print("runtime: m=", mp.id, "\n") + } } + i++ } - i++ } }) -- 2.48.1