From: Michael Anthony Knyszek Date: Thu, 13 Nov 2025 22:36:45 +0000 (+0000) Subject: cmd/trace: annotation proc start/stop with thread and proc always X-Git-Tag: go1.26rc1~292 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=704f841eab87462d4eefac07345c96f71fb6e964;p=gostls13.git cmd/trace: annotation proc start/stop with thread and proc always In the proc view, the thread ID is useful. In the thread view, the proc ID is useful. Add both in both cases forever more. Change-Id: I9cb7bd67a21ee17d865c25d73b2049b3da7aefbc Reviewed-on: https://go-review.googlesource.com/c/go/+/720402 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt Auto-Submit: Michael Knyszek --- diff --git a/src/cmd/trace/procgen.go b/src/cmd/trace/procgen.go index 060e62fe04..fc0a00e7ce 100644 --- a/src/cmd/trace/procgen.go +++ b/src/cmd/trace/procgen.go @@ -143,6 +143,13 @@ func (g *procGenerator) ProcTransition(ctx *traceContext, ev *trace.Event) { viewerEv := traceviewer.InstantEvent{ Resource: uint64(proc), Stack: ctx.Stack(viewerFrames(ev.Stack())), + + // Annotate with the thread and proc. The proc is redundant, but this is to + // stay consistent with the thread view, where it's useful information. + Arg: format.SchedCtxArg{ + ProcID: uint64(st.Resource.Proc()), + ThreadID: uint64(ev.Thread()), + }, } from, to := st.Proc() @@ -156,7 +163,6 @@ func (g *procGenerator) ProcTransition(ctx *traceContext, ev *trace.Event) { start = ctx.startTime } viewerEv.Name = "proc start" - viewerEv.Arg = format.ThreadIDArg{ThreadID: uint64(ev.Thread())} viewerEv.Ts = ctx.elapsed(start) ctx.IncThreadStateCount(ctx.elapsed(start), traceviewer.ThreadStateRunning, 1) } diff --git a/src/cmd/trace/threadgen.go b/src/cmd/trace/threadgen.go index c2e2c86f6c..7f9e7a72f0 100644 --- a/src/cmd/trace/threadgen.go +++ b/src/cmd/trace/threadgen.go @@ -138,14 +138,17 @@ func (g *threadGenerator) ProcTransition(ctx *traceContext, ev *trace.Event) { } } - type procArg struct { - Proc uint64 `json:"proc,omitempty"` - } st := ev.StateTransition() viewerEv := traceviewer.InstantEvent{ Resource: uint64(ev.Thread()), Stack: ctx.Stack(viewerFrames(ev.Stack())), - Arg: procArg{Proc: uint64(st.Resource.Proc())}, + + // Annotate with the thread and proc. The thread is redundant, but this is to + // stay consistent with the proc view. + Arg: format.SchedCtxArg{ + ProcID: uint64(st.Resource.Proc()), + ThreadID: uint64(ev.Thread()), + }, } from, to := st.Proc() @@ -159,7 +162,6 @@ func (g *threadGenerator) ProcTransition(ctx *traceContext, ev *trace.Event) { start = ctx.startTime } viewerEv.Name = "proc start" - viewerEv.Arg = format.ThreadIDArg{ThreadID: uint64(ev.Thread())} viewerEv.Ts = ctx.elapsed(start) // TODO(mknyszek): We don't have a state machine for threads, so approximate // running threads with running Ps. diff --git a/src/internal/trace/traceviewer/format/format.go b/src/internal/trace/traceviewer/format/format.go index 83f3276704..2ec4dd4bdc 100644 --- a/src/internal/trace/traceviewer/format/format.go +++ b/src/internal/trace/traceviewer/format/format.go @@ -74,6 +74,7 @@ type ThreadCountersArg struct { InSyscall int64 } -type ThreadIDArg struct { - ThreadID uint64 +type SchedCtxArg struct { + ThreadID uint64 `json:"thread,omitempty"` + ProcID uint64 `json:"proc,omitempty"` }