aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/trace
diff options
context:
space:
mode:
authorRhys Hiltner <rhys@justin.tv>2022-04-18 12:32:37 -0700
committerMichael Knyszek <mknyszek@google.com>2022-05-03 20:49:46 +0000
commit2c0a9884e0dc930c1a3596bc1decf183c8fdcf77 (patch)
tree33fedac2be0e9e3b8de4cb652d833a84b7889328 /src/cmd/trace
parent52bd1c4d6cc691aa60c71513695dba03062deb59 (diff)
downloadgo-2c0a9884e0dc930c1a3596bc1decf183c8fdcf77.tar.xz
runtime: add CPU samples to execution trace
When the CPU profiler and execution tracer are both active, report the CPU profile samples in the execution trace data stream. Include only samples that arrive on the threads known to the runtime, but include them even when running g0 (such as near the scheduler) or if there's no P (such as near syscalls). Render them in "go tool trace" as instantaneous events. For #16895 Change-Id: I0aa501a7b450c971e510961c0290838729033f7f Reviewed-on: https://go-review.googlesource.com/c/go/+/400795 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Rhys Hiltner <rhys@justin.tv> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/trace')
-rw-r--r--src/cmd/trace/trace.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/trace/trace.go b/src/cmd/trace/trace.go
index a0d742ac54..1cabc25ced 100644
--- a/src/cmd/trace/trace.go
+++ b/src/cmd/trace/trace.go
@@ -30,7 +30,6 @@ func init() {
http.Handle("/static/", http.FileServer(http.FS(staticContent)))
}
-
// httpTrace serves either whole trace (goid==0) or trace for goid goroutine.
func httpTrace(w http.ResponseWriter, r *http.Request) {
_, err := parseTrace()
@@ -719,6 +718,11 @@ func generateTrace(params *traceParams, consumer traceConsumer) error {
ctx.emitInstant(ev, "task start", "user event")
case trace.EvUserTaskEnd:
ctx.emitInstant(ev, "task end", "user event")
+ case trace.EvCPUSample:
+ if ev.P >= 0 {
+ // only show in this UI when there's an associated P
+ ctx.emitInstant(ev, "CPU profile sample", "")
+ }
}
// Emit any counter updates.
ctx.emitThreadCounters(ev)