Open AlexRouSg opened 5 years ago
CC @hyangah @pjweinbgo
CC @ianthehat
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?
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
How is a region defined? Can you give a specific example of the -with-regions
argument?
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.
@hyangah and @pjweinbgo, does the command line option in the comment above this one seem reasonable? Also is it implementable? Thanks.
@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 underlocalhost/traceregions
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.
@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.
@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.
Does this help?
@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.
I originally wanted a multiselect thing on the webpage, something like:
But thought that was too much so the command line was an alternative way to get the list to the handler.
command line requires reparsing of the trace. I think a simple text input box would be good enough.
I'm fine with a textbox
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.
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.