aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/trace
AgeCommit message (Collapse)Author
2021-08-17cmd/trace: use newTaskDesc to create taskDescLeonard Wang
Change-Id: I9bec8e2c4a9e1b9aa2baf883504200b5674844f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/335609 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com> Trust: Michael Pratt <mpratt@google.com>
2021-04-14runtime: move next_gc and last_next_gc into gcControllerStateMichael Anthony Knyszek
This change moves next_gc and last_next_gc into gcControllerState under the names heapGoal and lastHeapGoal respectively. These are fundamentally GC pacer related values, and so it makes sense for them to live here. Partially generated by rf ' ex . { memstats.next_gc -> gcController.heapGoal memstats.last_next_gc -> gcController.lastHeapGoal } ' except for updates to comments and gcControllerState methods, where they're accessed through the receiver, and trace-related renames of NextGC -> HeapGoal, while we're here. For #44167. Change-Id: I1e871ad78a57b01be8d9f71bd662530c84853bed Reviewed-on: https://go-review.googlesource.com/c/go/+/306603 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2021-03-13all: use HTML5 br tagsJohn Bampton
In HTML5 br tags don't need a closing slash Change-Id: Ic53c43faee08c5b1267daa9a02cc186b1c255ca1 GitHub-Last-Rev: 652208116944d01b23b8af8f1af485da5e916d32 GitHub-Pull-Request: golang/go#44283 Reviewed-on: https://go-review.googlesource.com/c/go/+/292370 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-21all: introduce and use internal/execabsRoland Shoemaker
Introduces a wrapper around os/exec, internal/execabs, for use in all commands. This wrapper prevents exec.LookPath and exec.Command from running executables in the current directory. All imports of os/exec in non-test files in cmd/ are replaced with imports of internal/execabs. This issue was reported by RyotaK. Fixes CVE-2021-3115 Fixes #43783 Change-Id: I0423451a6e27ec1e1d6f3fe929ab1ef69145c08f Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955304 Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Katie Hockman <katiehockman@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/284783 Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-08-12cmd/trace: move viewer data structs into cmd/internal/traceviewerMichael Matloob
The ViewerEvent, ViewerData and ViewerFrame structs are moved into cmd/internal/traceviewer, and renamed Event, Data, and Frame. The structs are the same, except for the following: A definition for the JSON "bp" field that's defined in the trace format, but missing in the structs has been added. Also, the Tid and Pid fields on Event have been renamed TID and PID to better match Go style. Finally, the footer field on ViewerData, which hasn't been used for a while, has been removed. This CL is in preparation for the usage of these structs by cmd/go's tracing functionality. Updates #38714 Change-Id: I345f23617b96d4629b876ae717f89d56a67e05a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/239098 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-04-21cmd/trace: fix the broken link in region pages and improve UXRohith Ravi
The trace tool had a broken link due to a parameter encoding error, which has been corrected. In addition: - the user regions page has been enhanced to include links to pprof style profiles for region specific io, block, syscall and schedwait profiles. - sortable table headers have a pointer cursor to indicate they're clickable. Fixes #38518 Change-Id: I26cd5157bd9753750f5f53ea03aac5d2d41b021c Reviewed-on: https://go-review.googlesource.com/c/go/+/228899 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-04-13cmd/trace: use the focustask mode for user task/region trace viewsHana (Hyang-Ah) Kim
The taskid mode is based on the goroutine-oriented trace view, which displays each goroutine as a separate row. This is good when inspecting the interaction and timeline among related goroutines, and the user region information (associated with each goroutine) in detail, but when many goroutines are involved, this mode does not scale. The focustask mode is based on the default trace view with the user task hierarchy at the top. Each row is a P and there are only a handful number of Ps in most cases, so browsers can handle this mode more gracefully. But, I had difficulty in displaying the user region information (because a goroutine can start/stop/ migrate across Ps, and visualizing the stack of regions nicely was complicated). It may be doable, but it's a work. This CL surfaces the hidden focustask mode. Moreover, use it as the default user task view mode. The taskid mode can be still accessible through 'goroutine view' links. Unlike taskid-based user annotation view that extends goroutine-based trace view, the focustask view Change-Id: Ib691a5e1dd14695fa70a0ae67bff62817025e8c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/227921 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-20cmd/trace: update to use WebComponents V0 polyfillHana (Hyang-Ah) Kim
Old trace viewer stopped working with Chrome M80+ because the old trace viewer heavily depended on WebComponents V0 which are deprecated. Trace viewer recently migrated to use WebComponents V0 polyfill (crbug.com/1036492). This CL brings in the newly updated trace_viewer_full.html (sync'd @ 9508452e) and updates the javascript snippet included in the /trace endpoint to use the polyfill. This brings in webcomponents.min.js copied from https://chromium.googlesource.com/catapult/+/9508452e18f130c98499cb4c4f1e1efaedee8962/third_party/polymer/components/webcomponentsjs/webcomponents.min.js That is necessary because the /trace endpoint needs to import the vulcanized trace_viewer_full.html. It's possible that some features are not working correctly with this polyfill. In that case, report the issue to crbug.com/1036492. There will be a warning message in the UI (yellow banner above the timeline) which can be hidden by clicking the 'hide' button. This allows to render the trace in browsers other than chrome in theory, but I observed some buttons and functions still don't work outside chrome. Fixes #34374. Change-Id: Ib575f756f5e6b22ad904ede6e4d224a995ebe259 Reviewed-on: https://go-review.googlesource.com/c/go/+/219997 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-01-02runtime: emit trace event in direct semaphore handoffRhys Hiltner
When a goroutine yields the remainder of its time to another goroutine during direct semaphore handoff (as in an Unlock of a sync.Mutex in starvation mode), it needs to signal that change to the execution tracer. The discussion in CL 200577 didn't reach consensus on how best to describe that, but pointed out that "traceEvGoSched / goroutine calls Gosched" could be confusing. Emit a "traceEvGoPreempt / goroutine is preempted" event in this case, to allow the execution tracer to find a consistent event ordering without being both specific and inaccurate about why the active goroutine has changed. Fixes #36186 Change-Id: Ic4ade19325126db2599aff6aba7cba028bb0bee9 Reviewed-on: https://go-review.googlesource.com/c/go/+/211797 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2019-05-06all: simplify code using "gofmt -s -w"Shulhan
Most changes are removing redundant declaration of type when direct instantiating value of map or slice, e.g. []T{T{}} become []T{{}}. Small changes are removing the high order of subslice if its value is the length of slice itself, e.g. T[:len(T)] become T[:]. The following file is excluded due to incompatibility with go1.4, - src/cmd/compile/internal/gc/ssa.go Change-Id: Id3abb09401795ce1e6da591a89749cba8502fb26 Reviewed-on: https://go-review.googlesource.com/c/go/+/166437 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-26all: fix typos as reported by 'misspell'Leon Klingele
Change-Id: I904b8655f21743189814bccf24073b6fbb9fc56d GitHub-Last-Rev: b032c14394c949f9ad7b18d019a3979d38d4e1fb GitHub-Pull-Request: golang/go#29997 Reviewed-on: https://go-review.googlesource.com/c/160421 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-02all: use "reports whether" consistently instead of "returns whether"Tobias Klauser
Follow-up for CL 147037 and after Brad noticed the "returns whether" pattern during the review of CL 150621. Go documentation style for boolean funcs is to say: // Foo reports whether ... func Foo() bool (rather than "returns whether") Created with: $ perl -i -npe 's/returns whether/reports whether/' $(git grep -l "returns whether" | grep -v vendor) Change-Id: I15fe9ff99180ad97750cd05a10eceafdb12dc0b4 Reviewed-on: https://go-review.googlesource.com/c/150918 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-22cmd/trace: revert internal/traceparserHana Kim
The performance improvement is not as big as we hoped. Until the API is feature complete, we postpone the release and avoid added complexity. This change was prepared by reverting all the changes affected src/cmd/trace and src/internal/traceparser packages after golang.org/cl/137635, and then bringing back MMU computation APIs (originally in src/internal/traceparser) to the src/internal/trace package. Revert "cmd/trace: use new traceparser to parse the raw trace files" This reverts https://golang.org/cl/145457 (commit 08816cb8d7ed16b9c804587ff02c1ad1c3af6cd5). Revert "internal/traceparser: provide parser that uses less space and parses segments of runtime trace files" This reverts https://golang.org/cl/137635 (commit daaf361f74c3665bcb364356c5a9dd9f536c78c3). Change-Id: Ic2a068a7dbaf4053cd9674ca7bde9c58e74385b4 Reviewed-on: https://go-review.googlesource.com/c/150517 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2018-11-05cmd/trace: notes on MMU view improvementsAustin Clements
Change-Id: Ib9dcdc76095f6718f1cdc83349503f52567c76d4 Reviewed-on: https://go-review.googlesource.com/c/60801 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-11-05cmd/trace: display p99.9, p99 and p95 MUTAustin Clements
This uses the mutator utilization distribution to compute the p99.9, p99, and p95 mutator utilization topograph lines and display them along with the MMU. Change-Id: I8c7e0ec326aa4bc00619ec7562854253f01cc802 Reviewed-on: https://go-review.googlesource.com/c/60800 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-11-05cmd/trace: expose MMU analysis flags in web UIAustin Clements
Change-Id: I672240487172380c9eef61837b41698021aaf834 Reviewed-on: https://go-review.googlesource.com/c/60798 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-11-05internal/trace: add "per-P" MMU analysisAustin Clements
The current MMU analysis considers all Ps together, so if, for example, one of four Ps is blocked, mutator utilization is 75%. However, this is less useful for understanding the impact on individual goroutines because that one blocked goroutine could be blocked for a very long time, but we still appear to have good utilization. Hence, this introduces a new flag that does a "per-P" analysis where the utilization of each P is considered independently. The MMU is then the combination of the MMU for each P's utilization function. Change-Id: Id67b980d4d82b511d28300cdf92ccbb5ae8f0c78 Reviewed-on: https://go-review.googlesource.com/c/60797 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-11-05internal/trace: flags for what to include in GC utilizationAustin Clements
Change-Id: I4ba963b003cb25b39d7575d423f17930d84f3f69 Reviewed-on: https://go-review.googlesource.com/c/60796 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-11-05cmd/trace: list and link to worst mutator utilization windowsAustin Clements
This adds the ability to click a point on the MMU graph to show a list of the worst 10 mutator utilization windows of the selected size. This list in turn links to the trace viewer to drill down on specifically what happened in each specific window. Change-Id: Ic1b72d8b37fbf2212211c513cf36b34788b30133 Reviewed-on: https://go-review.googlesource.com/c/60795 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-11-05cmd/trace: add minimum mutator utilization (MMU) plotAustin Clements
This adds an endpoint to the trace tool that plots the minimum mutator utilization curve using information on mark assists and GC pauses from the trace. This commit implements a fairly straightforward O(nm) algorithm for computing the MMU (and tests against an even more direct but slower algorithm). Future commits will extend and optimize this algorithm. This should be useful for debugging and understanding mutator utilization issues like #14951, #14812, #18155. #18534, #21107, particularly once follow-up CLs add trace cross-referencing. Change-Id: Ic2866869e7da1e6c56ba3e809abbcb2eb9c4923a Reviewed-on: https://go-review.googlesource.com/c/60790 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-11-02all: use "reports whether" consistently in the few places that didn'tBrad Fitzpatrick
Go documentation style for boolean funcs is to say: // Foo reports whether ... func Foo() bool (rather than "returns true if") This CL also replaces 4 uses of "iff" with the same "reports whether" wording, which doesn't lose any meaning, and will prevent people from sending typo fixes when they don't realize it's "if and only if". In the past I think we've had the typo CLs updated to just say "reports whether". So do them all at once. (Inspired by the addition of another "returns true if" in CL 146938 in fd_plan9.go) Created with: $ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true iff" | grep -v vendor) $ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true if" | grep -v vendor) Change-Id: Ided502237f5ab0d25cb625dbab12529c361a8b9f Reviewed-on: https://go-review.googlesource.com/c/147037 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-30cmd/trace: use new traceparser to parse the raw trace filesPeter Weinberger
Change-Id: I8b224ae48a2f8acd5a64c9ff283e97821479a9a8 Reviewed-on: https://go-review.googlesource.com/c/145457 Run-TryBot: Peter Weinberger <pjw@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-09-26all: use strings.ReplaceAll and bytes.ReplaceAll where applicableBrad Fitzpatrick
I omitted vendor directories and anything necessary for bootstrapping. (Tested by bootstrapping with Go 1.4) Updates #27864 Change-Id: I7d9b68d0372d3a34dee22966cca323513ece7e8a Reviewed-on: https://go-review.googlesource.com/137856 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-17cmd/trace: don't drop sweep slice detailsHana Kim
For sweep events, we used to modify the ViewerEvent returned from ctx.emitSlice later in order to embed more details about the sweep operation. The trick no longer works after the change https://golang.org/cl/92375 and caused a regression. ctx.emit method encodes the ViewerEvent, so any modification to the ViewerEvent object after ctx.emit returns will not be reflected. Refactor ctx.emitSlice, so ctx.makeSlice can be used when producing slices for SWEEP. ctx.emit* methods are meant to truely emit ViewerEvents. Fixes #27711 Change-Id: I0b733ebbbfd4facd8714db0535809ec3cab0833d Reviewed-on: https://go-review.googlesource.com/135775 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-30all: fix typosAlex Kohler
Change-Id: Icded6c786b7b185d5aff055f34e0cfe9e521826a Reviewed-on: https://go-review.googlesource.com/132176 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-23all: fix typos detected by github.com/client9/misspellKazuhiro Sera
Change-Id: Iadb3c5de8ae9ea45855013997ed70f7929a88661 GitHub-Last-Rev: ae85bcf82be8fee533e2b9901c6133921382c70a GitHub-Pull-Request: golang/go#26920 Reviewed-on: https://go-review.googlesource.com/128955 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-14runtime, sycall/js: add support for callbacks from JavaScriptRichard Musiol
This commit adds support for JavaScript callbacks back into WebAssembly. This is experimental API, just like the rest of the syscall/js package. The time package now also uses this mechanism to properly support timers without resorting to a busy loop. JavaScript code can call into the same entry point multiple times. The new RUN register is used to keep track of the program's run state. Possible values are: starting, running, paused and exited. If no goroutine is ready any more, the scheduler can put the program into the "paused" state and the WebAssembly code will stop running. When a callback occurs, the JavaScript code puts the callback data into a queue and then calls into WebAssembly to allow the Go code to continue running. Updates #18892 Updates #25506 Change-Id: Ib8701cfa0536d10d69bd541c85b0e2a754eb54fb Reviewed-on: https://go-review.googlesource.com/114197 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-21cmd/trace: fix a few bugs found by staticcheckDaniel Martí
First, the regions sort was buggy, as its last comparison was ineffective. Second, the insyscall and insyscallRuntime fields were unsigned, so the check for them being negative was pointless. Make them signed instead, to also prevent the possibility of underflows when decreasing numbers that might realistically be 0. Third, the color constants were all untyped strings except the first one. Be consistent with their typing. Change-Id: I4eb8d08028ed92589493c2a4b9cc5a88d83f769b Reviewed-on: https://go-review.googlesource.com/113895 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-08cmd/trace: handle invalid goid para in /traceHana (Hyang-Ah) Kim
Change-Id: I1cb7c8b70a5ae16386f6abb577c23d821f7ff7f0 Reviewed-on: https://go-review.googlesource.com/112197 Reviewed-by: Peter Weinberger <pjw@google.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-05-08cmd/trace: skip links for buckets with 0 countHana (Hyang-Ah) Kim
Change-Id: Ib1c2f7cc8e8f631ed9e74161699332f492d4cb0d Reviewed-on: https://go-review.googlesource.com/112196 Reviewed-by: Peter Weinberger <pjw@google.com>
2018-05-07runtime: replace system goroutine whitelist with symbol testAustin Clements
Currently isSystemGoroutine has a hard-coded list of known entry points into system goroutines. This list is annoying to maintain. For example, it's missing the ensureSigM goroutine. Replace it with a check that simply looks for any goroutine with runtime function as its entry point, with a few exceptions. This also matches the definition recently added to the trace viewer (CL 81315). Change-Id: Iaed723d4a6e8c2ffb7c0c48fbac1688b00b30f01 Reviewed-on: https://go-review.googlesource.com/81655 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2018-04-29cmd/trace: use different colors for tasksHana Kim
and assign the same colors for spans belong to the tasks (sadly, the trace viewer will change the saturation/ligthness for asynchronous slices so exact color mapping is impossible. But I hope they are not too far from each other) Change-Id: Idaaf0828a1e0dac8012d336dcefa1c6572ddca2e Reviewed-on: https://go-review.googlesource.com/109338 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-04-26cmd/trace: have tasks in a separate section (process group)Hana Kim
Also change tasks to be represented as "slices" instead of asynchronous events which are more efficiently represented in trace viewer data model. This change allows to utilize the flow events (arrows) to represent task hierarchies. Introduced RegionArgs and TaskArgs where the task id infomation and goroutine id informations are stored for information-purpose. Change-Id: I11bec7dd716fdfc5f94ea39661b2e51344367a6f Reviewed-on: https://go-review.googlesource.com/109337 Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-04-24cmd/trace: distinguish task endTimestamp and lastTimestampHana Kim
A task may have other user annotation events after the task ends. So far, task.lastTimestamp returned the task end event if the event available. This change introduces task.endTimestamp for that and makes task.lastTimestamp returns the "last" seen event's timestamp if the task is ended. If the task is not ended, both returns the last timestamp of the entire trace assuming the task is still active. This fixes the task-oriented trace view mode not to drop user annotation instances when they appear outside a task's lifespan. Adds a test. Change-Id: Iba1062914f224edd521b9ee55c6cd5e180e55359 Reviewed-on: https://go-review.googlesource.com/109175 Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-04-24runtime/trace: rename "Span" with "Region"Hana Kim
"Span" is a commonly used term in many distributed tracing systems (Dapper, OpenCensus, OpenTracing, ...). They use it to refer to a period of time, not necessarily tied into execution of underlying processor, thread, or goroutine, unlike the "Span" of runtime/trace package. Since distributed tracing and go runtime execution tracing are already similar enough to cause confusion, this CL attempts to avoid using the same word if possible. "Region" is being used in a certain tracing system to refer to a code region which is pretty close to what runtime/trace.Span currently refers to. So, replace that. https://software.intel.com/en-us/itc-user-and-reference-guide-defining-and-recording-functions-or-regions This CL also tweaks APIs a bit based on jbd and heschi's comments: NewContext -> NewTask and it now returns a Task object that exports End method. StartSpan -> StartRegion and it now returns a Region object that exports End method. Also, changed WithSpan to WithRegion and it now takes func() with no context. Another thought is to get rid of WithRegion. It is a nice concept but in practice, it seems problematic (a lot of code churn, and polluting stack trace). Already, the tracing concept is very low level, and we hope this API to be used with great care. Recommended usage will be defer trace.StartRegion(ctx, "someRegion").End() Left old APIs untouched in this CL. Once the usage of them are cleaned up, they will be removed in a separate CL. Change-Id: I73880635e437f3aad51314331a035dd1459b9f3a Reviewed-on: https://go-review.googlesource.com/108296 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: JBD <jbd@google.com>
2018-04-13cmd/trace: change span id computation for trace view useHana Kim
golang.org/cl/102697 attempted to fix the span presentation by utilizing the position of the span in the span slices of a task. But it is not complete either. First, id=0 is omitted in json encoding and the trace viewer silently drops entries with the missing id field, so we must avoid zero-value id. Second, it is possible that a goroutine handles multiple tasks. Then, id collisions will happen. This takes a simpler approach - have a counter that increments for every emitSpan call, and use the value as the id value. Change-Id: Idaa9505634acf6d327c6f00af32d8260955b85e1 Reviewed-on: https://go-review.googlesource.com/106755 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-10cmd/trace: pprof computation for span typesHana Kim
/spanio, /spanblock, /spansched, /spansyscall provide the pprof-style summary of span execution's io, block, scheduling, syscall latency distributions respectively. The computation logic for /io, /block, /sched, /syscall analysis was refactored and extended for reuse in these new types of analysis. Upon the analysis query, we create a map of goroutine id to time intervals based on the query parameter, that represents the interesting time intervals of matching goroutines. Only the events from the matching goroutines that fall into the intervals are considered in the pprof computation. The new endpoints are not yet hooked into other span analysis page (e.g. /userspan) yet. Change-Id: I80c3396e45a2d6631758710de67d132e5832c7ce Reviewed-on: https://go-review.googlesource.com/105822 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-10cmd/trace: skip GoroutineInSyscall in case time order errHana Kim
All tests involving trace collection and parsing still need handling of failures caused by #16755 (Timestamp issue) Fixes #24738 Change-Id: I6cd0f9c6f49854a22fad6fce1a00964c168aa614 Reviewed-on: https://go-review.googlesource.com/105821 Reviewed-by: Peter Weinberger <pjw@google.com>
2018-04-05cmd/trace: include taskless spans in /usertasks.Hana Kim
Change-Id: Id4e3407ba497a018d5ace92813ba8e9653d0ac7d Reviewed-on: https://go-review.googlesource.com/104976 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-04cmd/trace: avoid emitting traceview slice with 0 durationHana Kim
The trace viewer interprets the slice as a non-terminating time interval which is quite opposit to what trace records indicate (i.e., almostly immediately terminating time interval). As observed in the issue #24663 this can result in quite misleading visualization of the trace. Work around the trace viewer's issue by setting a small value (0.0001usec) as the duration if the time interval is not positive. Change-Id: I1c2aac135c194d0717f5c01a98ca60ffb14ef45c Reviewed-on: https://go-review.googlesource.com/104716 Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-04-04cmd/trace: implement /trace?focustask=<taskid> modeHana Kim
This mode is similar to the default traceview mode where the execution trace is presented in P-oriented way. Each row represents a P, and each slice represents the time interval of a goroutine's execution on the P. The difference is that, in this mode, only the execution of goroutines involved in the specified task is highlighted, and other goroutine execution or events are greyed out. So, users can focus on how a task is executed while considering other affecting conditions such as other goroutines, network events, or process scheduling. Example: https://user-images.githubusercontent.com/4999471/38116793-a6f995f0-337f-11e8-8de9-88eec2f2c497.png Here, for a while the program remained idle after the first burst of activity related to the task because all other goroutines were also being blocked or waiting for events, or no incoming network traffic (indicated by the lack of any network activity). This is a bit hard to discover when the usual task-oriented view (/trace?taskid=<taskid>) mode. Also, it simplifies the traceview generation mode logic. /trace ---> 0 /trace?goid ---> modeGoroutineOriented /trace?taskid ---> modeGoroutineOriented|modeTaskOriented /trace?focustask ---> modeTaskOriented Change-Id: Idcc0ae31b708ddfd19766f4e26ee7efdafecd3a5 Reviewed-on: https://go-review.googlesource.com/103555 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-03-29cmd/trace: make span tables prettyHana Kim
Mostly same as golang.org/cl/102156, except the parts that deal with different data types. Change-Id: I061b858b73898725e3bf175ed022c2e3e55fc485 Reviewed-on: https://go-review.googlesource.com/103158 Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-27cmd/trace: assign a unique span id for slice representationHana Kim
Spans are represented using Async Event types of chrome trace viewer. According to the doc, the 'id' should be unique within category, scope. https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1 Use the index in the task's span slice as the slice id, so it can be unique within the task. The scope is the task id which is unique. This fixes a visualization bug that caused incorrect or missing presentation of nested spans. Change-Id: If1537ee00247f71fa967abfe45569a9e7dbcdce7 Reviewed-on: https://go-review.googlesource.com/102697 Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-03-26cmd/trace: add /userspans, /userspan pagesHana Kim
Change-Id: Ifbefb659a8df3b079d69679871af444b179deaeb Reviewed-on: https://go-review.googlesource.com/102599 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-03-26internal/trace: compute span stats as computing goroutine statsHana Kim
Move part of UserSpan event processing from cmd/trace.analyzeAnnotations to internal/trace.GoroutineStats that returns analyzed per-goroutine execution information. Now the execution information includes list of spans and their execution information. cmd/trace.analyzeAnnotations utilizes the span execution information from internal/trace.GoroutineStats and connects them with task information. Change-Id: Ib7f79a3ba652a4ae55cd81ea17565bcc7e241c5c Reviewed-on: https://go-review.googlesource.com/101917 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Peter Weinberger <pjw@google.com>
2018-03-26cmd/trace: beautify goroutine pageHana (Hyang-Ah) Kim
- Summary: also includes links to pprof data. - Sortable table: sorting is done on server-side. The intention is that later, I want to add pagination feature and limit the page size the browser has to handle. - Stacked horizontal bar graph to present total time breakdown. - Human-friendly time representation. - No dependency on external fancy javascript libraries to allow it to function without an internet connection. Change-Id: I91e5c26746e59ad0329dfb61e096e11f768c7b73 Reviewed-on: https://go-review.googlesource.com/102156 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-03-21cmd/trace: remove unused variable in testsAlberto Donizetti
Unused variables in closures are currently not diagnosed by the compiler (this is Issue #3059), while go/types catches them. One unused variable in the cmd/trace tests is causing the go/types test that typechecks the whole standard library to fail: FAIL: TestStdlib (8.05s) stdlib_test.go:223: cmd/trace/annotations_test.go:241:6: gcTime declared but not used FAIL Remove it. Updates #24464 Change-Id: I0f1b9db6ae1f0130616ee649bdbfdc91e38d2184 Reviewed-on: https://go-review.googlesource.com/101815 Reviewed-by: Daniel Martí <mvdan@mvdan.cc>