summaryrefslogtreecommitdiff
path: root/cmd/podman/ps.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-10-23 18:40:34 -0500
committerbaude <bbaude@redhat.com>2018-10-25 07:50:46 -0500
commit3e5a5c68da9884ddb46cb9e84435956996347a4b (patch)
treea4b169f923fc64b3fadab0bab8de711d677eb3c5 /cmd/podman/ps.go
parent57f778aed93efc0961b1335bcd07c3c82a11da0a (diff)
downloadpodman-3e5a5c68da9884ddb46cb9e84435956996347a4b.tar.gz
podman-3e5a5c68da9884ddb46cb9e84435956996347a4b.tar.bz2
podman-3e5a5c68da9884ddb46cb9e84435956996347a4b.zip
Add --max-workers and heuristics for parallel operations
add a global flag for --max-workers so users can limit the number of parallel operations for a given function. also, when not limited by max-workers, we implement a heuristic function that returns the number of preferred parallel workers based on the number of CPUs and the given operation. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/ps.go')
-rw-r--r--cmd/podman/ps.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index a468f6121..fa333f952 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -20,6 +20,7 @@ import (
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/docker/go-units"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"k8s.io/apimachinery/pkg/fields"
)
@@ -300,7 +301,13 @@ func psCmd(c *cli.Context) error {
outputContainers = []*libpod.Container{latestCtr}
}
- pss := shared.PBatch(outputContainers, 8, opts)
+ maxWorkers := shared.Parallelize("ps")
+ if c.GlobalIsSet("max-workers") {
+ maxWorkers = c.GlobalInt("max-workers")
+ }
+ logrus.Debugf("Setting maximum workers to %d", maxWorkers)
+
+ pss := shared.PBatch(outputContainers, maxWorkers, opts)
if opts.Sort != "" {
pss, err = sortPsOutput(opts.Sort, pss)
if err != nil {