diff options
author | Aleksandr Razumov <ar@gortc.io> | 2019-12-15 20:57:23 +0300 |
---|---|---|
committer | Aleksandr Razumov <ar@gortc.io> | 2019-12-15 21:12:43 +0300 |
commit | 8782f0e287df2a2fd9f9dfb3f0e1589cc15a4f91 (patch) | |
tree | d08d7f3a04d700b2edc2538d80ef9d3f0137989c /runsc/boot/config.go | |
parent | 6b424530397e5100b08628efe8f6c62178daa70b (diff) |
Set CPU number to CPU quota
When application is not cgroups-aware, it can spawn excessive threads
which often defaults to CPU number.
Introduce a opt-in flag that will set CPU number accordingly to CPU
quota (if available).
Fixes #1391
Diffstat (limited to 'runsc/boot/config.go')
-rw-r--r-- | runsc/boot/config.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runsc/boot/config.go b/runsc/boot/config.go index 72a33534f..7841d1a7a 100644 --- a/runsc/boot/config.go +++ b/runsc/boot/config.go @@ -250,6 +250,12 @@ type Config struct { // multiple tests are run in parallel, since there is no way to pass // parameters to the runtime from docker. TestOnlyTestNameEnv string + + // CPUNumFromQuota sets CPU number count to available CPU quota, using + // least integer value greater than or equal to quota. + // + // E.g. 0.2 CPU quota would result in 1, and 1.9 in 2. + CPUNumFromQuota bool } // ToFlags returns a slice of flags that correspond to the given Config. @@ -282,6 +288,9 @@ func (c *Config) ToFlags() []string { "--software-gso=" + strconv.FormatBool(c.SoftwareGSO), "--overlayfs-stale-read=" + strconv.FormatBool(c.OverlayfsStaleRead), } + if c.CPUNumFromQuota { + f = append(f, "--cpu-num-from-quota") + } // Only include these if set since it is never to be used by users. if c.TestOnlyAllowRunAsCurrentUserWithoutChroot { f = append(f, "--TESTONLY-unsafe-nonroot=true") |