-
Notifications
You must be signed in to change notification settings - Fork 600
pprof: take cpu and memory profiles by setting environment variables #2746
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
Conversation
cmd/buildx/debug.go
Outdated
| } | ||
|
|
||
| func setupCPUProfile(ctx context.Context) (stop func()) { | ||
| if cpuProfile := os.Getenv("DOCKER_BUILDX_CPU_PROFILE"); cpuProfile != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could just be BUILDX_CPU_PROFILE to be consistent with other envs: https://docs.docker.com/build/building/variables/#build-tool-configuration-variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I also added a snippet to capture the log when this is run as a plugin too. It was previously just for standalone runs.
de4f299 to
2fe225c
Compare
|
is this for 0.18.0? |
tonistiigi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are couple of places in commands package that call os.Exit() directly and would skip these defers. Can be follow-up but needs tracking issue then.
cmd/buildx/main.go
Outdated
| } | ||
|
|
||
| func runStandalone(cmd *command.DockerCli) error { | ||
| stopProfiles := setupDebugProfiles(context.TODO()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call this from main() directly to avoid duplicate calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be a single defer line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a style thing. I find this easier to read.
When run in standalone mode, the environment variables `DOCKER_BUILDX_CPU_PROFILE` and `DOCKER_BUILDX_MEM_PROFILE` will cause profiles to be written by the CLI. Signed-off-by: Jonathan A. Sternberg <[email protected]>
2fe225c to
cf7a9aa
Compare
|
Refactored the run into a single function that calls |
|
@dvdksn For docs follow-up we could add docker/docs#21214 to contributing docs. |
When run in standalone mode, the environment variables
DOCKER_BUILDX_CPU_PROFILEandDOCKER_BUILDX_MEM_PROFILEwill cause profiles to be written by the CLI.