diff options
| author | Hana Kim <hakim@google.com> | 2018-03-02 15:52:30 -0500 |
|---|---|---|
| committer | Hyang-Ah Hana Kim <hyangah@gmail.com> | 2018-03-09 01:34:12 +0000 |
| commit | 476f71c9586c18235cdc678b2e8d7fadd7570d3d (patch) | |
| tree | 08d9ba63ed0bcb8e4c3ecd572fb8b190790b1726 /src/cmd/trace/annotations.go | |
| parent | 53c416396fafb9f73b24159134836bbbd2266d29 (diff) | |
| download | go-476f71c9586c18235cdc678b2e8d7fadd7570d3d.tar.xz | |
cmd/trace: remove unrelated arrows in task-oriented traceview
Also grey out instants that represent events occurred outside the
task's span. Furthermore, if the unrelated instants represent user
annotation events but not for the task of the interest, skip rendering
completely.
This helps users to focus on the task-related events better.
UI screen shot:
https://gist.github.com/hyangah/1df5d2c8f429fd933c481e9636b89b55#file-golang-org_cl_99035
Change-Id: I2b5aef41584c827f8c1e915d0d8e5c95fe2b4b65
Reviewed-on: https://go-review.googlesource.com/99035
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Diffstat (limited to 'src/cmd/trace/annotations.go')
| -rw-r--r-- | src/cmd/trace/annotations.go | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/cmd/trace/annotations.go b/src/cmd/trace/annotations.go index c7c0b637c7..aa72a50e72 100644 --- a/src/cmd/trace/annotations.go +++ b/src/cmd/trace/annotations.go @@ -446,12 +446,42 @@ func (task *taskDesc) overlappingGCDuration(evs []*trace.Event) (overlapping tim return overlapping } +// overlappingInstant returns true if the instantaneous event, ev, occurred during +// any of the task's span if ev is a goroutine-local event, or overlaps with the +// task's lifetime if ev is a global event. +func (task *taskDesc) overlappingInstant(ev *trace.Event) bool { + if isUserAnnotationEvent(ev) && task.id != ev.Args[0] { + return false // not this task's user event. + } + + ts := ev.Ts + taskStart := task.firstTimestamp() + taskEnd := task.lastTimestamp() + if ts < taskStart || taskEnd < ts { + return false + } + if ev.P == trace.GCP { + return true + } + + // Goroutine local event. Check whether there are spans overlapping with the event. + goid := ev.G + for _, span := range task.spans { + if span.goid != goid { + continue + } + if span.firstTimestamp() <= ts && ts <= span.lastTimestamp() { + return true + } + } + return false +} + // overlappingDuration returns whether the durational event, ev, overlaps with // any of the task's span if ev is a goroutine-local event, or overlaps with // the task's lifetime if ev is a global event. It returns the overlapping time // as well. func (task *taskDesc) overlappingDuration(ev *trace.Event) (time.Duration, bool) { - // TODO: check whether ev is a 'durational' event. start := ev.Ts end := lastTimestamp() if ev.Link != nil { @@ -463,9 +493,13 @@ func (task *taskDesc) overlappingDuration(ev *trace.Event) (time.Duration, bool) } goid := ev.G + goid2 := ev.G + if ev.Link != nil { + goid2 = ev.Link.G + } - // This event is a global event (G=0) - if goid == 0 { + // This event is a global GC event + if ev.P == trace.GCP { taskStart := task.firstTimestamp() taskEnd := task.lastTimestamp() o := overlappingDuration(taskStart, taskEnd, start, end) @@ -476,7 +510,7 @@ func (task *taskDesc) overlappingDuration(ev *trace.Event) (time.Duration, bool) var overlapping time.Duration var lastSpanEnd int64 // the end of previous overlapping span for _, span := range task.spans { - if span.goid != goid { + if span.goid != goid && span.goid != goid2 { continue } spanStart, spanEnd := span.firstTimestamp(), span.lastTimestamp() @@ -925,3 +959,11 @@ func describeEvent(ev *trace.Event) string { } return "" } + +func isUserAnnotationEvent(ev *trace.Event) bool { + switch ev.Type { + case trace.EvUserLog, trace.EvUserSpan, trace.EvUserTaskCreate, trace.EvUserTaskEnd: + return true + } + return false +} |
