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 · 34 comments
Open

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

matloob opened this issue Apr 27, 2020 · 34 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@matloob
Copy link
Contributor

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 commented Apr 27, 2020

@gopherbot
Copy link

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

@josharian
Copy link
Contributor

Tracing like #15736?

@matloob
Copy link
Contributor Author

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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 28, 2020
@andybons andybons added this to the Unplanned milestone Apr 28, 2020
@andybons andybons added the GoCommand cmd/go label Apr 28, 2020
@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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
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

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

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

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

@gopherbot
Copy link

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>
@gopherbot
Copy link

Change https://go.dev/cl/419554 mentions this issue: cmd/go: add Context parameter to download function

gopherbot pushed a commit that referenced this issue Oct 12, 2022
Updates #38714

Change-Id: Ie5c7761ec003f84e649fa4c90be184a5ff6a0879
Reviewed-on: https://go-review.googlesource.com/c/go/+/419554
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Nov 3, 2022
Updates golang#38714

Change-Id: Ie5c7761ec003f84e649fa4c90be184a5ff6a0879
Reviewed-on: https://go-review.googlesource.com/c/go/+/419554
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@gopherbot
Copy link

Change https://go.dev/cl/452456 mentions this issue: cmd/go: propagate Context arguments through modfetch methods

gopherbot pushed a commit that referenced this issue May 18, 2023
For #56886.
For #38714.

Change-Id: I15c4a8673407d3423d7e203d645c6d0fb780d192
Reviewed-on: https://go-review.googlesource.com/c/go/+/452456
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants