Kubernetes Introduces Improved cgroup v1 to v2 CPU Conversion Formula
The Kubernetes project has announced the implementation of an enhanced conversion formula for mapping cgroup v1 CPU shares to cgroup v2 CPU weights. This update addresses critical performance and configuration issues arising from the transition to cgroup v2, which replaced the linear mapping approach defined in KEP-2254. The previous linear formula caused two significant problems: it reduced CPU priority for Kubernetes workloads against non-Kubernetes system processes, assigning a weight of approximately 39 instead of the default 100 for a 1 CPU request. Additionally, it resulted in unmanageable granularity for small CPU requests, such as converting 100m CPU requests to a weight of only 4, hindering fine-grained resource distribution within sub-cgroups. The new quadratic formula ensures that key values align correctly, mapping minimum, default, and maximum ranges accurately. Specifically, it preserves the equivalence between the cgroup v1 default share of 1024 and the cgroup v2 default weight of 100. This enhancement is crucial for maintaining expected workload priorities and supporting future features like writable cgroups for unprivileged containers, ensuring smoother operations on systems utilizing cgroup v2.
Wire timeline
Kubernetes Introduces Improved cgroup v1 to v2 CPU Conversion Formula
The Kubernetes project has announced the implementation of an enhanced conversion formula for mapping cgroup v1 CPU shares to cgroup v2 CPU weights. This update addresses critical performance and configuration issues arising from the transition to cgroup v2, which replaced the linear mapping approach defined in KEP-2254. The previous linear formula caused two significant problems: it reduced CPU priority for Kubernetes workloads against non-Kubernetes system processes, assigning a weight of approximately 39 instead of the default 100 for a 1 CPU request. Additionally, it resulted in unmanageable granularity for small CPU requests, such as converting 100m CPU requests to a weight of only 4, hindering fine-grained resource distribution within sub-cgroups. The new quadratic formula ensures that key values align correctly, mapping minimum, default, and maximum ranges accurately. Specifically, it preserves the equivalence between the cgroup v1 default share of 1024 and the cgroup v2 default weight of 100. This enhancement is crucial for maintaining expected workload priorities and supporting future features like writable cgroups for unprivileged containers, ensuring smoother operations on systems utilizing cgroup v2.
Kubernetes Blog