pprof: take cpu and memory profiles by setting environment variables#2746
Conversation
| } | ||
|
|
||
| func setupCPUProfile(ctx context.Context) (stop func()) { | ||
| if cpuProfile := os.Getenv("DOCKER_BUILDX_CPU_PROFILE"); cpuProfile != "" { |
There was a problem hiding this comment.
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.
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.
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.
| } | ||
|
|
||
| func runStandalone(cmd *command.DockerCli) error { | ||
| stopProfiles := setupDebugProfiles(context.TODO()) |
There was a problem hiding this comment.
Why not call this from main() directly to avoid duplicate calls.
There was a problem hiding this comment.
This can also be a single defer line
There was a problem hiding this comment.
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.