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 <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/src/runtime/trace2.go b/src/runtime/trace2.go
index 1a58015..59ea190 100644
--- a/src/runtime/trace2.go
+++ b/src/runtime/trace2.go
@@ -443,6 +443,7 @@
// 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 @@
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++
}
})