diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2021-08-23 13:48:10 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2021-08-23 16:19:47 +0200 |
commit | 7b54a5fbe861298d554b201b508250f62609cc56 (patch) | |
tree | 8b204a9f947f7558877cace97a49406b148680a6 /cmd/podman/root.go | |
parent | 2de56a5f41473e8f759972ec568089e9cddc0f98 (diff) | |
download | podman-7b54a5fbe861298d554b201b508250f62609cc56.tar.gz podman-7b54a5fbe861298d554b201b508250f62609cc56.tar.bz2 podman-7b54a5fbe861298d554b201b508250f62609cc56.zip |
profiling: higher memory sampling rate
Increase the memory-sampling rate to the same default as
github.com/pkg/profile. Allow for custom rates by reading
the `MemProfileRate` env variable.
[NO TESTS NEEDED] since it's a dev only flag and not part of CI.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/root.go')
-rw-r--r-- | cmd/podman/root.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 1275f5631..371ded9a8 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -6,6 +6,7 @@ import ( "path/filepath" "runtime" "runtime/pprof" + "strconv" "strings" "github.com/containers/common/pkg/completion" @@ -194,6 +195,17 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { return err } } + if cmd.Flag("memory-profile").Changed { + // Same value as the default in github.com/pkg/profile. + runtime.MemProfileRate = 4096 + if rate := os.Getenv("MemProfileRate"); rate != "" { + r, err := strconv.Atoi(rate) + if err != nil { + return err + } + runtime.MemProfileRate = r + } + } if cfg.MaxWorks <= 0 { return errors.Errorf("maximum workers must be set to a positive number (got %d)", cfg.MaxWorks) |