From 5764bf1badcc73d93c4ef6e6d5ce9a1705178724 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Wed, 22 Nov 2017 15:58:32 -0800 Subject: [PATCH] cmd/containerd-shim: set GOMAXPROCS to 2 The shim doesn't need massive concurrency and a bunch of CPUs to do its job correctly. We can reduce the number of threads to save memory at little cost to performance. Signed-off-by: Stephen J Day --- cmd/containerd-shim/main_unix.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go index f1163d0d2..31164f7dd 100644 --- a/cmd/containerd-shim/main_unix.go +++ b/cmd/containerd-shim/main_unix.go @@ -60,6 +60,13 @@ func main() { if debugFlag { logrus.SetLevel(logrus.DebugLevel) } + + if os.Getenv("GOMAXPROCS") == "" { + // If GOMAXPROCS hasn't been set, we default to a value of 2 to reduce + // the number of Go stacks present in the shim. + runtime.GOMAXPROCS(2) + } + if err := executeShim(); err != nil { fmt.Fprintf(os.Stderr, "containerd-shim: %s\n", err) os.Exit(1)