summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
authorBen Buzbee <bbuzbee@cloudflare.com>2020-09-17 00:52:01 +0000
committerBen Buzbee <bbuzbee@cloudflare.com>2020-09-30 20:32:33 +0000
commit12731f4271ea1c42d7501b9e626044cf9aa369ca (patch)
tree2e01af8f6506f9cc949aef10a5cc4c694769841a /runsc
parentae59e529791e4763aaa25eee818605f17699fc67 (diff)
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.
Diffstat (limited to 'runsc')
-rw-r--r--runsc/boot/loader.go1
1 files changed, 1 insertions, 0 deletions
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