aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/trace
AgeCommit message (Collapse)Author
2017-02-13cmd/trace: document the final step to use pprof-like profilesJaana Burcu Dogan
The tutorial ends without mentioning how to use the generated pprof-like profile with the pprof tool. This may be very trivial for users who are already very familiar with the Go tools, but for the newcomers, it saves a lot of time to finalize the tutorial with an example of `go tool pprof` invocation. Change-Id: Idf034eb4bfb9672ef10190e66fcbf873e8f08f6a Reviewed-on: https://go-review.googlesource.com/36803 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-02-10cmd/trace: Record mark assists in execution tracesHeschi Kreinick
During the mark phase of garbage collection, goroutines that allocate may be recruited to assist. This change creates trace events for mark assists and displays them similarly to sweep assists in the trace viewer. Mark assists are different than sweeps in that they can be preempted, so displaying them in the trace viewer is a little tricky -- we may need to synthesize multiple slices for one mark assist. This could have been done in the parser instead, but I thought it might be preferable to keep the parser as true to the event stream as possible. Change-Id: I381dcb1027a187a354b1858537851fa68a620ea7 Reviewed-on: https://go-review.googlesource.com/36015 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-11-18cmd/trace: fix goroutine viewAustin Clements
Currently, trace processing interleaves state/statistics updates and emitting trace viewer objects. As a result, if events are being filtered, either by time or by goroutines, we'll miss those state/statistics updates. At best, this leads to bad statistics; however, since we're now strictly checking G state transitions, it usually leads to a failure to process the trace if there is any filtering. Fix this by separating state updates from emitting trace object. State updates are done before filtering, so we always have correct state information and statistics. Trace objects are only emitted if we pass the filter. To determine when we need to emit trace counters, rather than duplicating the knowledge of which events might modify statistics, we keep track of the previously emitted counters and emit a trace counter object whenever these have changed. Fixes #17719. Change-Id: Ic66e3ddaef60d1acaaf2ff4c62baa5352799cf99 Reviewed-on: https://go-review.googlesource.com/32810 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-11-02internal/pprof/profile: new package, moved from cmd/internal/pprof/profileRuss Cox
This allows both the runtime and the cmd/pprof code to use the package, just like we do for internal/trace. Change-Id: I7606977284e1def36c9647354c58e7c1e93dba6b Reviewed-on: https://go-review.googlesource.com/32452 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-28runtime, cmd/trace: track goroutines blocked on GC assistsAustin Clements
Currently when a goroutine blocks on a GC assist, it emits a generic EvGoBlock event. Since assist blocking events and, in particular, the length of the blocked assist queue, are important for diagnosing GC behavior, this commit adds a new EvGoBlockGC event for blocking on a GC assist. The trace viewer uses this event to report a "waiting on GC" count in the "Goroutines" row. This makes sense because, unlike other blocked goroutines, these goroutines do have work to do, so being blocked on a GC assist is quite similar to being in the "runnable" state, which we also report in the trace viewer. Change-Id: Ic21a326992606b121ea3d3d00110d8d1fdc7a5ef Reviewed-on: https://go-review.googlesource.com/30704 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-28cmd/trace: track each G's state explicitlyAustin Clements
Currently the trace tool tracks an overall counts of goroutine states, but not the states of any individual goroutine. We're about to add more sophisticated blocked-state tracking, so add this tracking and base the state counts off the tracked goroutine states. Change-Id: I943ed61782436cf9540f4ee26c5561715c5b4a1d Reviewed-on: https://go-review.googlesource.com/30703 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-28runtime, cmd/trace: annotate different mark worker typesAustin Clements
Currently mark workers are shown in the trace as regular goroutines labeled "runtime.gcBgMarkWorker". That's somewhat unhelpful to an end user because of the opaque label and particularly unhelpful to runtime developers because it doesn't distinguish the different types of mark workers. Fix this by introducing a variant of the GoStart event called GoStartLabel that lets the runtime indicate a label for a goroutine execution span and using this to label mark worker executions as "GC (<mode>)" in the trace viewer. Since this bumps the trace version to 1.8, we also add test data for 1.7 traces. Change-Id: Id7b9c0536508430c661ffb9e40e436f3901ca121 Reviewed-on: https://go-review.googlesource.com/30702 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-12cmd/trace: add option to output pprof filesFilippo Valsorda
The trace tool can generate some interesting profiles, but it was only exposing them as svg through the web UI. This adds command line options to generate the raw pprof file. Change-Id: I52e4f909fdca6f65c3616add444e3892783640f4 Reviewed-on: https://go-review.googlesource.com/23324 Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-11cmd/trace: fix a runnable goroutine count bugHyang-Ah (Hana) Kim
When starting tracing, EvGoCreate events are added for existing goroutines that may have been blocking in syscall. EvGoCreate increments the runnable goroutine count. This change makes the following EvGoInSyscall event decrement the runnable goroutine count because we now know that goroutine is in syscall, and not runnable. Made generateTrace return an error, at any given time, the number of runnable/running/insyscall goroutines becomes non-negative. Added a basic test that checks the number of runnable/running goroutines don't include the goroutines in syscall - the test failed before this change. Change-Id: Ib732c382e7bd17158a437576f9d589ab89097ce6 Reviewed-on: https://go-review.googlesource.com/25552 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-07cmd/trace: label mark termination spans as suchAustin Clements
Currently these are labeled "MARK", which was accurate in the STW collector, but these really indicate mark termination now, since marking happens for the full duration of the concurrent GC. Re-label them as "MARK TERMINATION" to clarify this. Change-Id: Ie98bd961195acde49598b4fa3f9e7d90d757c0a6 Reviewed-on: https://go-review.googlesource.com/30018 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-07cmd/trace: move process-wide GC events to their own rowAustin Clements
Currently, the process-wide GC state is attributed to the P that happened to perform the allocation that exceeded the GC trigger. This is pretty arbitrary and makes it hard to see when GC is running since the GC spans are intermingled with a lot of other trace noise. The current display is particularly confusing because it creates three sub-rows in the P row that can overlap each other. Usually a P has just two sub-rows: one showing the current G and another showing that G's activity. However, because GC is attributed to a proc, it winds up as a third row that neither subsumes nor is subsumed by any other row. This in turn screws up the trace's layout and results in overlapping events. Fix these problems by creating a new dedicated row like the existing "Network" and "Timer" rows and displaying process-wide GC events in this row. Mark termination and sweep events still appear in their respective P rows because these are meaningfully attributed. Change-Id: Ie1a1c6cf8c446e4b043f10f3968f91ff1b546d15 Reviewed-on: https://go-review.googlesource.com/30017 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-09-14cmd: add internal/browser packageJosh Bleecher Snyder
cmd/cover, cmd/trace, and cmd/pprof all open browsers. 'go bug' will soon also open a browser. It is time to unify the browser-handling code. Change-Id: Iee6b443e21e938aeaaac366a1aefb1afbc7d9b2c Reviewed-on: https://go-review.googlesource.com/29160 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-12cmd/trace: split large traces into partsDmitry Vyukov
Trace viewer cannot handle traces larger than 256MB (limit on js string size): https://github.com/catapult-project/catapult/issues/627 And even that is problematic (chrome hangs and crashes). Split large traces into 100MB parts. Somewhat clumsy, but I don't see any other solution (other than rewriting trace viewer). At least it works reliably now. Fixes #15482 Change-Id: I993b5f43d22072c6f5bd041ab5888ce176f272b2 Reviewed-on: https://go-review.googlesource.com/22731 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-05-03cmd/trace: make binary argument optionalDmitry Vyukov
1.7 traces embed symbol info and we now generate symbolized pprof profiles, so we don't need the binary. Make binary argument optional as 1.5 traces still need it. Change-Id: I65eb13e3d20ec765acf85c42d42a8d7aae09854c Reviewed-on: https://go-review.googlesource.com/22410 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Austin Clements <austin@google.com>
2016-04-22cmd/trace: generate new pprof profilesDmitry Vyukov
Generate new protobuf pprof profiles with embed symbol info. This makes program binary unnecessary. Change-Id: Ie628439c13c5e34199782031138102c83ea50621 Reviewed-on: https://go-review.googlesource.com/21873 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
2016-04-14misc/trace: update trace viewer htmlDmitry Vyukov
The old trace-viewer is broken since Chrome 49: https://bugs.chromium.org/p/chromium/issues/detail?id=569417 It was fixed in: https://github.com/catapult-project/catapult/commit/506457cbd726324f327b80ae11f46c1dfeb8710d This change updates trace-viewer to the latest version (now it is called catapult). This version has a bug in the lean config that we use, though: https://github.com/catapult-project/catapult/issues/2247 So use full config for now (it works, but leads to larger html). When the bug is fixed we need to switch back to lean config (issue #15302). Change-Id: Ifb8d782ced66e3292d81c5604039fe18eaf267c5 Reviewed-on: https://go-review.googlesource.com/22013 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11internal/trace: support parsing of 1.5 tracesDmitry Vyukov
1. Parse out version from trace header. 2. Restore handling of 1.5 traces. 3. Restore optional symbolization of traces. 4. Add some canned 1.5 traces for regression testing (http benchmark trace, runtime/trace stress traces, plus one with broken timestamps). Change-Id: Idb18a001d03ded8e13c2730eeeb37c5836e31256 Reviewed-on: https://go-review.googlesource.com/21803 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2016-04-08runtime: emit file:line info into tracesDmitry Vyukov
This makes traces self-contained and simplifies trace workflow in modern cloud environments where it is simpler to reach a service via HTTP than to obtain the binary. Change-Id: I6ff3ca694dc698270f1e29da37d5efaf4e843a0d Reviewed-on: https://go-review.googlesource.com/21732 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-21cmd/trace: don't fail when no browser is availableDavid du Colombier
When there is no browser available on the system, we should print the URL instead of failing. Change-Id: I4a2b099e17609394273eff150062c285d76bbac1 Reviewed-on: https://go-review.googlesource.com/13774 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-08-15cmd/trace: fix static file referenceDmitry Vyukov
Use runtime.GOROOT instead of os.Getenv("GOROOT") to reference trace-viewer html file. GOROOT env var is not necessary set, runtime.GOROOT has a default value for such case. Change-Id: I906a720f6822915bd9575756e6cbf6d622857c2b Reviewed-on: https://go-review.googlesource.com/13593 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-22runtime/trace: add new packageDmitry Vyukov
Move tracing functions from runtime/pprof to the new runtime/trace package. Fixes #9710 Change-Id: I718bcb2ae3e5959d9f72cab5e6708289e5c8ebd5 Reviewed-on: https://go-review.googlesource.com/12511 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-02cmd/trace: log errors to console in AJAX handlerDmitry Vyukov
Fixes #11508 Change-Id: I72e83893b76f75685d6edfe65ca6691d97539226 Reviewed-on: https://go-review.googlesource.com/11864 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-01cmd/trace: fix time scaleDmitry Vyukov
Integrate the latest trace-viewer changes. It now handles nanoseconds without any issues (thanks to @egonelbre!). So change timestamps from microseconds to nanoseconds. Change-Id: I010f27effde7e80c9992e6f276f6912354d27df4 Reviewed-on: https://go-review.googlesource.com/11244 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Egon Elbre <egonelbre@gmail.com>
2015-06-30cmd/trace: sort procsDmitry Vyukov
If you have more than 10 procs, then currently they are sorted alphabetically as 0, 10, 11, ..., 19, 2, 20, ... Assign explicit order to procs so that they are sorted numerically. Change-Id: I6d978d2cd439aa2fcbcf147842a643f9073eef75 Reviewed-on: https://go-review.googlesource.com/11750 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18cmd/trace: gracefully handle empty profilesDmitry Vyukov
Return a meaningful message when a profile is empty. Also rename "IO blocking" to "Network blocking", currently only network blocking is captured. Fixes #11098 Change-Id: Ib6f1292b8ade4805756fcb6696ba1fca8f9f39a9 Reviewed-on: https://go-review.googlesource.com/11243 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-14cmd/trace: fix panic in goroutine profileDmitry Vyukov
In generateTrace we check that event timestamp is within the interesting range. Then later in traceContext.time we double check event time. However, for some events (e.g. emitSlice) we convert time of ev.Link (slice end) rather than ev itself (slice begin). Slice end can be outside of the interesting time range, and so traceContext.time crashes. Remove the check in traceContext.time, check in generateTrace loop is sufficient. Change-Id: If94e93b5653c5816c0a8dcdd920f15df97616835 Reviewed-on: https://go-review.googlesource.com/11100 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-14misc/trace: update trace viewerDmitry Vyukov
Update to tip to fix #11003 (not possible to select events in chromium). Fixed #11003 Change-Id: Ibba5d39ca809cfd5cb79c9e6d152b00899d49e08 Reviewed-on: https://go-review.googlesource.com/11062 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-04-18cmd/...: fix vet issues and cull dead codeJosh Bleecher Snyder
Change-Id: Ied0eab872950793b34dd2268055b29c702b07e99 Reviewed-on: https://go-review.googlesource.com/9081 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-03-11cmd/trace: move goroutine analysis code to internal/traceDmitry Vyukov
This allows to test goroutine analysis code in runtime/pprof tests. Also fix a nil-deref crash in goroutine analysis code that happens on runtime/pprof tests. Change-Id: Id7884aa29f7fe4a8d7042482a86fe434e030461e Reviewed-on: https://go-review.googlesource.com/7301 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-11cmd/trace: dump thread id on proc startDmitry Vyukov
Augment ProcStart events with OS thread id. This helps in scheduler locality analysis. Change-Id: I93fea75d3072cf68de66110d0b59d07101badcb5 Reviewed-on: https://go-review.googlesource.com/7302 Reviewed-by: Keith Randall <khr@golang.org>
2015-03-10runtime: remove runtime frames from stacks in tracesDmitry Vyukov
Stip uninteresting bottom and top frames from trace stacks. This makes both binary and json trace files smaller, and also makes stacks shorter and more readable in the viewer. Change-Id: Ib9c80ccc280504f0e235f867f53f1d2652c41583 Reviewed-on: https://go-review.googlesource.com/5523 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
2015-02-20cmd/trace: add new commandDmitry Vyukov
Trace command allows to visualize and analyze traces. Run as: $ go tool trace binary trace.file The commands opens web browser with the main page, which contains links for trace visualization, blocking profiler, network IO profiler and per-goroutine traces. Also move trace parser from runtime/pprof/trace_parser_test.go to internal/trace/parser.go, so that it can be shared between tests and the command. Change-Id: Ic97ed59ad6e4c7e1dc9eca5e979701a2b4aed7cf Reviewed-on: https://go-review.googlesource.com/3601 Reviewed-by: Andrew Gerrand <adg@golang.org>