From 58c8fecec240a3d9b6a1da1a717d5e4e71c25f04 Mon Sep 17 00:00:00 2001 From: Joshua T Corbin Date: Fri, 16 Feb 2018 09:42:48 -0800 Subject: [PATCH] Use floor(quota) rather than ceil(quota) --- CHANGELOG.md | 6 ++++++ internal/runtime/cpu_quota_linux.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1673761..8738813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v1.2.0 (unreleased) + +- Fixed quota clamping to always round down rather than up; Rather than + guaranteeing constant throttling at saturation, instead assume that the + fractional CPU was added as a hedge for factors outside of Go's scheduler. + ## v1.1.0 (2017-11-10) - Log the new value of `GOMAXPROCS` rather than the current value. diff --git a/internal/runtime/cpu_quota_linux.go b/internal/runtime/cpu_quota_linux.go index cb742b5..37699c3 100644 --- a/internal/runtime/cpu_quota_linux.go +++ b/internal/runtime/cpu_quota_linux.go @@ -41,7 +41,7 @@ func CPUQuotaToGOMAXPROCS(minValue int) (int, CPUQuotaStatus, error) { return -1, CPUQuotaUndefined, err } - maxProcs := int(math.Ceil(quota)) + maxProcs := int(math.Floor(quota)) if minValue > 0 && maxProcs < minValue { return minValue, CPUQuotaMinUsed, nil }