Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: add support for tracing to visualize build behavior #38714

Open
matloob opened this issue Apr 27, 2020 · 32 comments
Open

cmd/go: add support for tracing to visualize build behavior #38714

matloob opened this issue Apr 27, 2020 · 32 comments

Comments

@matloob
Copy link
Contributor

@matloob matloob commented Apr 27, 2020

I'd like to add a GODEBUG option to cmd/go to emit traces so that we can visualize build behavior. For now it will emit a runtime trace but maybe in the future we might use @ianthehat's events library. Maybe in the future it could become a flag, but for now adding it to GODEBUG should be safe in the sense that it doesn't affect the formal interface of the go command.

@matloob
Copy link
Contributor Author

@matloob matloob commented Apr 27, 2020

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 27, 2020

Change https://golang.org/cl/230378 mentions this issue: cmd/go: add a trace option to GODEBUG

@josharian
Copy link
Contributor

@josharian josharian commented Apr 27, 2020

Tracing like #15736?

@matloob
Copy link
Contributor Author

@matloob matloob commented Apr 28, 2020

Yes, though my understanding is that --debug-actiongraph only has timing information for build actions, and doesn't cover cmd/go's behavior before actions are executed.

@andybons andybons added this to the Unplanned milestone Apr 28, 2020
@andybons andybons added the GoCommand label Apr 28, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 12, 2020

Change https://golang.org/cl/237683 mentions this issue: cmd/go: add a debug-trace flag to generate traces

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 12, 2020

Change https://golang.org/cl/237684 mentions this issue: cmd/go: add Context parameter to base.command.Run

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 17, 2020

Change https://golang.org/cl/238541 mentions this issue: cmd/go: propagate context into PackagesForBuild and Do for tracing

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 17, 2020

Change https://golang.org/cl/238542 mentions this issue: cmd/go/internal/trace: add function to distinguish Goroutines

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 17, 2020

Change https://golang.org/cl/238543 mentions this issue: cmd/go: add trace events for each action

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 19, 2020

Change https://golang.org/cl/239083 mentions this issue: cmd/go: mark trace flows between actions

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 19, 2020

Change https://golang.org/cl/239098 mentions this issue: cmd/trace: move viewer data structs into cmd/internal/traceviewer

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 22, 2020

Change https://golang.org/cl/239438 mentions this issue: cmd/go: process -debug-trace flag for cmd/test and cmd/vet

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 22, 2020

Change https://golang.org/cl/239437 mentions this issue: cmd/go: add tracing instrumentation to leod.TestPackagesFor

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 24, 2020

Change https://golang.org/cl/239750 mentions this issue: cmd/go: do context propagation for tracing downloads

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 24, 2020

Change https://golang.org/cl/239749 mentions this issue: cmd/go: add span for modload.LoadBuildList

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 26, 2020

Change https://golang.org/cl/240181 mentions this issue: cmd/go: do context propagation for tracing downloads

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 13, 2020

Change https://golang.org/cl/242365 mentions this issue: cmd/go: add trace spans for the skeleton of get

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 15, 2020

Change https://golang.org/cl/242785 mentions this issue: cmd/go: rewrite mvs.buildList to not use par.Work

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 15, 2020

Change https://golang.org/cl/242786 mentions this issue: cmd/go: add tracing for querying and downloading from the proxy

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 21, 2020

Change https://golang.org/cl/243949 mentions this issue: cmd/go: annotate ImportPathsQuiet and modload.(*loader).doPkg

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 21, 2020

Change https://golang.org/cl/243948 mentions this issue: cmd/go: add tracing to mvs.buildList

gopherbot pushed a commit that referenced this issue Aug 12, 2020
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>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
Updates #38714

Change-Id: I14da982d405074d65ccf5521d431df1bf1734f9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230378
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
If cmd/go is provided with a -debug-trace=<file> option, cmd/go will write an
execution trace to that file.

Updates #38714

Change-Id: I3e6521343902c08266a0292f4280298a3bf8b725
Reviewed-on: https://go-review.googlesource.com/c/go/+/237683
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
One small step to start propagating the context in
cmd/go for tracing purposes.

Updates #38714

Change-Id: Ibb6debeb9233f84d55f0e81244487355cbe7b82c
Reviewed-on: https://go-review.googlesource.com/c/go/+/237684
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
This change propagates context into PackagesForErrors and Do for
the purpose of tracing, and calls trace.StartSpan on PackagesForErrors
and Do, so that the trace now shows the broad outline of where
the "Loading" and "Execution" phases are in the build.

Updates #38714

Change-Id: Ib9a7cf7030210f68f76663d1c8a7461e0a226611
Reviewed-on: https://go-review.googlesource.com/c/go/+/238541
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
trace.StartGoroutine will associate the trace information on the context
with a new chrome profiler thread id. The chrome profiler doesn't
expect multiple trace events to have the same thread id, so this
will allow us to display concurrent events on the trace.

Updates #38714

Change-Id: I81690861df4f444f14f02a99e0fe551395b660a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/238542
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
This change adds a trace event for each action and also
annotates each of the action execution goroutines with trace.Goroutine
so that the actions eaxecuted by each goroutine appear on different threads in
the chrome trace viewer.

Updates #38714

Change-Id: I5db21bf473b77544e83d4f8d6addb72921e7eea9
Reviewed-on: https://go-review.googlesource.com/c/go/+/238543
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
This could help make it easier to identify blocking
dependencies when examining traces. Flows can be turned
off when viewing traces to remove potential distractions.

Updates #38714

Change-Id: I66ab00317f93afb762769707edd2d9233aa11669
Reviewed-on: https://go-review.googlesource.com/c/go/+/239083
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
This change adds tracing instrumentation into load.TestPackagesFor,
propagating context through its callers.

Updates #38714

Change-Id: I93adbb1caff26defb740f2f984d5111824fa7a78
Reviewed-on: https://go-review.googlesource.com/c/go/+/239437
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
These commands are build-like commands that do their own flag
processing, so the value of debug-trace isn't available until
the command starts running. Start tracing in the cmd's run
function.

Updates #38714

Change-Id: Ibff820b2b49072cb313defc84dd5eda6dd02180f
Reviewed-on: https://go-review.googlesource.com/c/go/+/239438
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
This change adds context, and a span to modload.LoadBuildList and
propagates context into modload.BuildList. It's the start
of a run of CLs to add trace spans for module operations.

Updates #38714

Change-Id: Iaa6860d5b15de1f0d3e28c3743eb40409583c6b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/239749
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
This change does context propagation (and only context propagation)
necessary to add context to modfetch.Download and pkg.LoadImport.
This was done by adding context to their callers, and then
adding context to all call-sites, and then repeating adding
context to callers of those enclosing functions and their
callers until none were left. In some cases the call graph expansion
was pruned by using context.TODOs.

The next CL will add a span to Download. I kept it out of this
change to avoid making it any larger (and harder to review)
than it needs to be.

Updates #38714

Change-Id: Ibc044e45f2c4d76721728dedf2bbfa5245374b51
Reviewed-on: https://go-review.googlesource.com/c/go/+/240181
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 12, 2020
Unlike the changes in golang.org/cl/240062, I don't think we can use the
semaphore channel to tell when all the tasks are done, so we need a waitgroup
to perform that function.

Updates #38714

Change-Id: Ia325af11c9e2cd5ccc2e70d4693335271b0b2b38
Reviewed-on: https://go-review.googlesource.com/c/go/+/242785
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>
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248322 mentions this issue: cmd/go: mark trace flows between actions

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248328 mentions this issue: cmd/go: rewrite mvs.buildList to not use par.Work

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248327 mentions this issue: cmd/go: do context propagation for tracing downloads

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248324 mentions this issue: cmd/go: process -debug-trace flag for cmd/test and cmd/vet

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248319 mentions this issue: cmd/go/internal/trace: add function to distinguish goroutines

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248323 mentions this issue: cmd/go: add tracing instrumentation to load.TestPackagesFor

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248325 mentions this issue: cmd/go: add span for modload.LoadBuildList

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 12, 2020

Change https://golang.org/cl/248320 mentions this issue: cmd/go: add trace events for each action

gopherbot pushed a commit that referenced this issue Aug 17, 2020
trace.StartGoroutine will associate the trace information on the context
with a new chrome profiler thread id. The chrome profiler doesn't
expect multiple trace events to have the same thread id, so this
will allow us to display concurrent events on the trace.

Updates #38714

Change-Id: I888b0cce15a5a01db66366716fdd85bf86c832cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/248319
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
This change adds a trace event for each action and also
annotates each of the action execution goroutines with trace.Goroutine
so that the actions eaxecuted by each goroutine appear on different threads in
the chrome trace viewer.

Updates #38714

Change-Id: I2e58dc5606b2e3f7f87076a61e1cc6a2014255c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/248320
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
This could help make it easier to identify blocking
dependencies when examining traces. Flows can be turned
off when viewing traces to remove potential distractions.

Updates #38714

Change-Id: Ibfd3f1a1861e3cac31addb053a2fca7ee796c4d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/248322
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
This change adds tracing instrumentation into load.TestPackagesFor,
propagating context through its callers.

Updates #38714

Change-Id: I80fefaf3116ccccffaa8bb7613a656bda867394c
Reviewed-on: https://go-review.googlesource.com/c/go/+/248323
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
These commands are build-like commands that do their own flag
processing, so the value of debug-trace isn't available until
the command starts running. Start tracing in the cmd's run
function.

Updates #38714

Change-Id: I4d633e6ee907bf09feac52c2aff3daceb9b20e12
Reviewed-on: https://go-review.googlesource.com/c/go/+/248324
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
This change adds context, and a span to modload.LoadBuildList and
propagates context into modload.BuildList. It's the start
of a run of CLs to add trace spans for module operations.

Updates #38714

Change-Id: I0d58dd394051526338092dc9a5ec29a9e087e4e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/248325
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
This change does context propagation (and only context propagation)
necessary to add context to modfetch.Download and pkg.LoadImport.
This was done by adding context to their callers, and then
adding context to all call-sites, and then repeating adding
context to callers of those enclosing functions and their
callers until none were left. In some cases the call graph expansion
was pruned by using context.TODOs.

The next CL will add a span to Download. I kept it out of this
change to avoid making it any larger (and harder to review)
than it needs to be.

Updates #38714

Change-Id: I5bf2d599aafef67334c384dfccd5e255198c85b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/248327
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Aug 17, 2020
This CL adds tracing spans for modload.queryPattern, modload.queryProxy,
modload.QueryPattern, modload.QueryPattern.queryModule,
modload.queryPrefixModules and modfetch.Download.

Updates #38714

Change-Id: I537c7fa4f466c691c1b60ec73ef8a2277af49cd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/242786
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>
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 18, 2020

Change https://golang.org/cl/249017 mentions this issue: cmd/go: revert 3 CLs affecting par.Work, context propagation, tracing

gopherbot pushed a commit that referenced this issue Aug 18, 2020
This reverts the following changes:

•	cmd/go: add tracing for querying and downloading from the proxy
	CL 242786, commit 1a35583

•	cmd/go: do context propagation for tracing downloads
	CL 248327, commit c0cf190

•	cmd/go/internal: remove some users of par.Work
	CL 248326, commit f30044a

Reason for revert: broke linux 386 and amd64 longtest builders.

The problem started with CL 248326, but CL 248327 and CL 242786
are reverted as well due to conflicts.

Updates #38714.
Fixes #40861.

Change-Id: I68496b4e5a27e47a42183553c3a645b288edac83
Reviewed-on: https://go-review.googlesource.com/c/go/+/249017
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 18, 2020

Change https://golang.org/cl/249021 mentions this issue: cmd/go: do context propagation for tracing downloads

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 18, 2020

Change https://golang.org/cl/249022 mentions this issue: cmd/go: add tracing for querying and downloading from the proxy

gopherbot pushed a commit that referenced this issue Aug 20, 2020
This change does context propagation (and only context propagation)
necessary to add context to modfetch.Download and pkg.LoadImport.
This was done by adding context to their callers, and then
adding context to all call-sites, and then repeating adding
context to callers of those enclosing functions and their
callers until none were left. In some cases the call graph expansion
was pruned by using context.TODOs.

The next CL will add a span to Download. I kept it out of this
change to avoid making it any larger (and harder to review)
than it needs to be.

Updates #38714

Change-Id: I7a03416e04a14ca71636d96f2c1bda2c4c30d348
Reviewed-on: https://go-review.googlesource.com/c/go/+/249021
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
gopherbot pushed a commit that referenced this issue Aug 20, 2020
This CL adds tracing spans for modload.queryPattern, modload.queryProxy,
modload.QueryPattern, modload.QueryPattern.queryModule,
modload.queryPrefixModules and modfetch.Download.

Updates #38714

Change-Id: I91af3f022a6e18ab8d9c1d9b0ccf4928b6c236bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/249022
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.