diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2025-08-05 21:37:07 +0000 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2025-08-15 14:01:30 -0700 |
| commit | 4a7fde922ff12dce9d4e00f1b1e658fa907e488d (patch) | |
| tree | 74b130e4a531bc6bce41cb34e66431d3966a80b8 /src/runtime/trace.go | |
| parent | cb814bd5bc3f0575e8d0e26370c05456770cb3da (diff) | |
| download | go-4a7fde922ff12dce9d4e00f1b1e658fa907e488d.tar.xz | |
internal/trace: add end-of-generation signal to trace
This change takes the EvEndOfGeneration event and promotes it to a real
event that appears in the trace.
This allows the trace parser to unambiguously identify truncated traces
vs. broken traces. It also makes a lot of the logic around parsing
simpler, because there's no more batch spilling necessary.
Fixes #73904.
Change-Id: I37c359b32b6b5f894825aafc02921adeaacf2595
Reviewed-on: https://go-review.googlesource.com/c/go/+/693398
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/trace.go')
| -rw-r--r-- | src/runtime/trace.go | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 0d71ad445c..2c712469ea 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -754,24 +754,7 @@ func traceRegisterLabelsAndReasons(gen uintptr) { // was on has been returned, ReadTrace returns nil. The caller must copy the // returned data before calling ReadTrace again. // ReadTrace must be called from one goroutine at a time. -func ReadTrace() []byte { - for { - buf := readTrace() - - // Skip over the end-of-generation signal which must not appear - // in the final trace. - if len(buf) == 1 && tracev2.EventType(buf[0]) == tracev2.EvEndOfGeneration { - continue - } - return buf - } -} - -// readTrace is the implementation of ReadTrace, except with an additional -// in-band signal as to when the buffer is for a new generation. -// -//go:linkname readTrace runtime/trace.runtime_readTrace -func readTrace() (buf []byte) { +func ReadTrace() (buf []byte) { top: var park bool systemstack(func() { @@ -842,7 +825,7 @@ func readTrace0() (buf []byte, park bool) { if !trace.headerWritten { trace.headerWritten = true unlock(&trace.lock) - return []byte("go 1.25 trace\x00\x00\x00"), false + return []byte("go 1.26 trace\x00\x00\x00"), false } // Read the next buffer. |
