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

proposal: cmd/trace: generate trace graph for custom region selection #30895

Open
AlexRouSg opened this issue Mar 18, 2019 · 17 comments
Open

proposal: cmd/trace: generate trace graph for custom region selection #30895

AlexRouSg opened this issue Mar 18, 2019 · 17 comments

Comments

@AlexRouSg
Copy link
Contributor

@AlexRouSg AlexRouSg commented Mar 18, 2019

I propose that cmd/trace should have an option in the web UI to generate a trace graph for an arbitrary list of user defined regions.

I want/need to see the timing between certain user defined regions and having such an option in the web ui would be very useful. I could just dump them all into the same task but this means recompiling the program and changing code just to change what regions get shown together. Also if the program failed to call task.End() for any reason, then the trace graph doesn't get generated at all.

@gopherbot gopherbot added this to the Proposal milestone Mar 18, 2019
@gopherbot gopherbot added the Proposal label Mar 18, 2019
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Mar 20, 2019

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Apr 12, 2019

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Apr 24, 2019

The actual viewer UI is part of Chrome DevTools (now Catapult) and is taken from upstream.
The bare-bones web pages around it are generated by cmd/trace, and we could do filtering in those before invoking the DevTools. But how would the regions get defined? That is, how would you express to the tool which regions to keep in the filtered trace?

@AlexRouSg

This comment has been minimized.

Copy link
Contributor Author

@AlexRouSg AlexRouSg commented Apr 24, 2019

Was thinking of a multi list selector in the web UI but if that's too much, I guess a command line arg would be good enough.

Maybe go tool trace -with-regions <Task>/<Region> <No task region> <Region from any task> trace.out
Then it generates a trace graph with those regions and maybe put it under localhost/traceregions

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 24, 2019

How is a region defined? Can you give a specific example of the -with-regions argument?

@AlexRouSg

This comment has been minimized.

Copy link
Contributor Author

@AlexRouSg AlexRouSg commented Apr 24, 2019

When I say "regions" I meant trace regions users defined by using runtime/Trace

e.g.

package main

import (
	"context"
	"fmt"
	"runtime/trace"
)

func Example() {
	trace.WithRegion(context.Background(), "foo", func() {
		fmt.Println("foo")
	})

	ctx, task := trace.NewTask(ctx, "awesomeTask")
	trace.WithRegion(ctx, "bar", func() {
		fmt.Println("awesomeTask/bar")
	})

	task.End()
}

And then you execute go test -trace=out.trace && go tool trace -with-regions="awesometask/bar foo" out.trace if a task isn't specified then it pulls in all regions matching the name from any task.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented May 7, 2019

@hyangah and @pjweinbgo, does the command line option in the comment above this one seem reasonable? Also is it implementable? Thanks.

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented May 8, 2019

@AlexRouSg can you elaborate what information you want to see from the output visualization?

  • Do you want to see other activities such as goroutines, P assignment, and syscalls associated with the specified task/region?

  • Or do you just want to see only the task/region timing info (nothing other than that)?

  • What specific visualization options(trace? goroutine? ...) do you want to be altered?

  • What do you mean by "localhost/traceregions" here?

Maybe go tool trace -with-regions <Task>/<Region> <No task region> <Region from any task> trace.out
Then it generates a trace graph with those regions and maybe put it under localhost/traceregions

@AlexRouSg

This comment has been minimized.

Copy link
Contributor Author

@AlexRouSg AlexRouSg commented May 8, 2019

Do you want to see other activities such as goroutines, P assignment, and syscalls associated with the specified task/region?

Or do you just want to see only the task/region timing info (nothing other than that)?

What specific visualization options(trace? goroutine? ...) do you want to be altered?

Like what you get when you go to http://127.0.0.1:49854/trace?taskid=1#0:1284.290663 but instead of seeing events for the selected task, you see events for a selected list of regions that may or may not be in the same task or have a task.

What do you mean by "localhost/traceregions" here?

The URL for accessing the graph. I don't really care about this part.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Jul 2, 2019

@hyangah and @pjweinbgo, does this seem like something that can be implemented? I'm not asking you to implement it, just to weigh in on whether it makes sense to accept as a path forward. Thanks.

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Jul 2, 2019

@rsc I don't think I fully understand the proposed feature even though I agree that cmd/trace needs more love. Sketch of the desired visualization, or concrete examples may be helpful.

@AlexRouSg

This comment has been minimized.

Copy link
Contributor Author

@AlexRouSg AlexRouSg commented Jul 2, 2019

Does this help?

new

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Jul 2, 2019

@AlexRouSg why not just implementing an handler in the server-side, take the region name or regexp as a text input field, and pass it to the handler? (instead of the command line flag).

The visualization needs to be careful when handling the case where there are so many matching regions and tasks.

@AlexRouSg

This comment has been minimized.

Copy link
Contributor Author

@AlexRouSg AlexRouSg commented Jul 2, 2019

I originally wanted a multiselect thing on the webpage, something like:
image

But thought that was too much so the command line was an alternative way to get the list to the handler.

@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Jul 2, 2019

command line requires reparsing of the trace. I think a simple text input box would be good enough.

@AlexRouSg

This comment has been minimized.

Copy link
Contributor Author

@AlexRouSg AlexRouSg commented Jul 2, 2019

I'm fine with a textbox

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Jul 16, 2019

It sounds like there is an agreement here about a text input box for selecting the trace subsection. I will mark this as accepted but I don't think we plan to do it any time soon. Help welcome.

@rsc rsc modified the milestones: Proposal, accepted Jul 16, 2019
@rsc rsc removed this from the accepted milestone Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.