From 12731f4271ea1c42d7501b9e626044cf9aa369ca Mon Sep 17 00:00:00 2001 From: Ben Buzbee Date: Thu, 17 Sep 2020 00:52:01 +0000 Subject: Use consistent thread configuration for sandbox go runtime With cgroups configured NumCPU is correct, however GOMAXPROCS is still derived from total host core count and ignores cgroup restrictions. This can lead to different and undesired behavior across different hosts. For example, the total number of threads in the guest process will be larger on machines with more cores. This change configures the go runtime for the sandbox to only use the number of threads consistent with its restrictions. --- runsc/boot/loader.go | 1 + 1 file changed, 1 insertion(+) (limited to 'runsc/boot') diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index 4940ea96a..7fb6dc043 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -282,6 +282,7 @@ func New(args Args) (*Loader, error) { args.NumCPU = runtime.NumCPU() } log.Infof("CPUs: %d", args.NumCPU) + runtime.GOMAXPROCS(args.NumCPU) if args.TotalMem > 0 { // Adjust the total memory returned by the Sentry so that applications that -- cgit v1.2.3