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

Enable live pprof at /.pprof/ #71

Merged
merged 3 commits into from
Nov 28, 2022

Conversation

vadmeste
Copy link
Member

@vadmeste vadmeste commented Nov 24, 2022

Running go tool pprof http://localhost:8080/minio/pprof/profile?seconds=30 will get CPU
profiling for 20 seconds

Supported profilers are: goroutine, threadcreate, heap, allocs, block,
mutex, symbol, trace and profile (cpu profiling)

@klauspost
Copy link

@vadmeste I find the HTTP profilers to be much more useful since it doesn't require restarting. Maybe we could expose them on a separate port, so adding a parameter --pprof=":6060" would expose profiling on a separate port.

There is also a standard HTTP interface to profiling data. In an HTTP server, adding
import _ "net/http/pprof" will install handlers for a few URLs under /debug/pprof/. Then you can run go tool pprof with a single argument—the URL to your server’s profiling data and it will download and examine a live profile.

go tool pprof http://localhost:6060/debug/pprof/profile   # 30-second CPU profile
go tool pprof http://localhost:6060/debug/pprof/heap      # heap profile
go tool pprof http://localhost:6060/debug/pprof/block     # goroutine blocking profile
  • You will need to add the pprof to a custom mux, but there are easy functions for that. I can send a PR if you'd like.

@harshavardhana
Copy link
Member

@vadmeste I find the HTTP profilers to be much more useful since it doesn't require restarting. Maybe we could expose them on a separate port, so adding a parameter --pprof=":6060" would expose profiling on a separate port.

There is also a standard HTTP interface to profiling data. In an HTTP server, adding
import _ "net/http/pprof" will install handlers for a few URLs under /debug/pprof/. Then you can run go tool pprof with a single argument—the URL to your server’s profiling data and it will download and examine a live profile.

go tool pprof http://localhost:6060/debug/pprof/profile   # 30-second CPU profile
go tool pprof http://localhost:6060/debug/pprof/heap      # heap profile
go tool pprof http://localhost:6060/debug/pprof/block     # goroutine blocking profile
  • You will need to add the pprof to a custom mux, but there are easy functions for that. I can send a PR if you'd like.

This is better as @klauspost suggested

Running `go tool pprof
http://localhost:8080/minio/pprof/profile?seconds=30` will get CPU
profiling for 20 seconds

Supported profilers are: goroutine, threadcreate, heap, allocs, block,
mutex, symbol, trace and profile (cpu profiling)
@vadmeste vadmeste changed the title Add --profile to run Sidekick with profiling enabled Enable live pprof at /minio/pprof/ Nov 25, 2022
@vadmeste
Copy link
Member Author

@klauspost I made the change, by the way, this does not require any flag.. it can be always enabled

@klauspost
Copy link

@vadmeste The reason for the separate port is for safety reasons. While adding it to the default port is a lot easier, both for use and setup it does allow anyone to access potentially resource intensive calls.

@vadmeste
Copy link
Member Author

@vadmeste The reason for the separate port is for safety reasons. While adding it to the default port is a lot easier, both for use and setup it does allow anyone to access potentially resource intensive calls.

But this will require a flag and a restart

@klauspost
Copy link

Yes, why I wrote that "adding it to the default port is a lot easier, both for use and setup". But it doesn't look like something we would like to have exposed externally.

But it is easier to block a port.

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
Co-authored-by: Harshavardhana <harsha@minio.io>
@harshavardhana harshavardhana changed the title Enable live pprof at /minio/pprof/ Enable live pprof at /.pprof/ Nov 28, 2022
@harshavardhana harshavardhana merged commit b4973ee into minio:master Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants