aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-11-13 22:36:45 +0000
committerGopher Robot <gobot@golang.org>2025-11-13 15:16:31 -0800
commit704f841eab87462d4eefac07345c96f71fb6e964 (patch)
tree32164902dc71a83f6502dbba2f8dba459687f211
parent17a02b910697800032aa686548992a554e8e9d82 (diff)
downloadgo-704f841eab87462d4eefac07345c96f71fb6e964.tar.xz
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
-rw-r--r--src/cmd/trace/procgen.go8
-rw-r--r--src/cmd/trace/threadgen.go12
-rw-r--r--src/internal/trace/traceviewer/format/format.go5
3 files changed, 17 insertions, 8 deletions
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"`
}