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/trace: add a name/desc to goroutines which are inactive when get a pprof trace #49994

Open
yifhao opened this issue Dec 6, 2021 · 4 comments
Open
Labels
Milestone

Comments

@yifhao
Copy link

@yifhao yifhao commented Dec 6, 2021

What version of Go are you using (go version)?

$ go version
nothing to do with go version

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
nothing to do with go env

What did you do?

I got a pprof trace, then watch it on browser. I saw the last line 'N=xxx' with no link or name.
it's easy to make a mistake about what it is meaning, many people may think it's the total number of goroutines.

What did you expect to see?

I read the source code, and then find: the last line is the num of goroutines which are created before trace taken, and inactive during the trace.

I think may add a name/desc to it, like: inactive when trace.
in httpGoroutines func add:
image
and then see:
image

What did you see instead?

image

@seankhliao seankhliao changed the title cmd/trace/goroutines.go: add a name/desc to goroutines which are inactive when get a pprof trace cmd/trace: add a name/desc to goroutines which are inactive when get a pprof trace Dec 6, 2021
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Dec 6, 2021

@yifhao
Copy link
Author

@yifhao yifhao commented Dec 6, 2021

cmd/trace/goroutines.go

var templGoroutines = template.Must(template.New("").Parse(`
<html>
<body>
Goroutines: <br>
{{range $}}
  <a href="/goroutine?id={{.ID}}">{{.Name}}</a> N={{.N}} <br>
{{end}}
</body>
</html>
`))

image
a href tag without text which means no action in tracing will display a line like this in browser .
image

@prattmic prattmic added this to the Go1.19 milestone Dec 6, 2021
@prattmic
Copy link
Member

@prattmic prattmic commented Dec 6, 2021

Thanks for the report. I think your suggested fix is reasonable, feel free to send a CL (note we are in freeze and thus won't submit before ~Feb).

Ideally we'd do even better and actually attach each goroutine's stack trace to the initial EvGoCreate. This should be possible since the world is stopped, but I could see that making starting tracing take a lot longer, especially with 5000+ goroutines, which I imagine is why it was avoided in the first place.

@prattmic
Copy link
Member

@prattmic prattmic commented Dec 6, 2021

Ideally we'd do even better and actually attach each goroutine's stack trace to the initial EvGoCreate. This should be possible since the world is stopped, but I could see that making starting tracing take a lot longer, especially with 5000+ goroutines, which I imagine is why it was avoided in the first place.

Actually, we already have gp.startpc with the initial goroutine entrypoint (in fact TraceStart even uses it as the "stack id" for EvGoCreate). If the cost is low enough, we could findfunc(gp.startpc) and include a func name string id along with the EvGoCreate event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants