Skip to content

Commit 639f3b6

Browse files
authored
Merge pull request #51484 from wongchar/uncore-align-1.34
Add feature blog: introduce prefer-align-cpus-by-uncore-cache
2 parents f0b4c75 + 1e0b287 commit 639f3b6

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed
731 KB
Loading
169 KB
Loading
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
layout: blog
3+
title: 'Kubernetes v1.34: Introducing CPU Manager Static Policy Option for Uncore Cache Alignment'
4+
date: 2025-xx-xx
5+
draft: true
6+
slug: kubernetes-v1-34-prefer-align-by-uncore-cache-cpumanager-static-policy-optimization
7+
author: Charles Wong (AMD)
8+
---
9+
10+
A new CPU Manager Static Policy Option called `prefer-align-cpus-by-uncorecache` was introduced in Kubernetes v1.32 as an alpha feature, and has graduated to **beta** in Kubernetes v1.34.
11+
This CPU Manager Policy Option is designed to optimize performance for specific workloads running on processors with a _split uncore cache_ architecture.
12+
In this article, I'll explain what that means and why it's useful.
13+
14+
## Understanding the feature
15+
16+
### What is uncore cache?
17+
Until relatively recently, nearly all mainstream computer processors had a
18+
monolithic last-level-cache cache that was shared across every core in a multiple
19+
CPU package.
20+
This monolithic cache is also referred to as _uncore cache_
21+
(because it is not linked to a specific core), or as Level 3 cache.
22+
As well as the Level 3 cache, there is other cache, commonly called Level 1 and Level 2 cache,
23+
that **is** associated with a specific CPU core.
24+
25+
In order to reduce access latency between the CPU cores and their cache, recent AMD64 and ARM
26+
architecture based processors have introduced a _split uncore cache_ architecture,
27+
where the last-level-cache is divided into multiple physical caches,
28+
that are aligned to specific CPU groupings within the physical package.
29+
The shorter distances within the CPU package help to reduce latency.
30+
![Diagram showing monolithic cache on the left and split cache on the right](./mono_vs_split_uncore.png)
31+
32+
Kubernetes is able to place workloads in a way that accounts for the cache
33+
topology within the CPU package(s).
34+
35+
### Cache-aware workload placement
36+
The matrix below shows the [CPU-to-CPU latency](https://github.com/nviennot/core-to-core-latency) measured in nanoseconds (lower is better) when
37+
passing a packet between CPUs, via its cache coherence protocol on a processor that
38+
uses split uncore cache.
39+
In this example, the processor package consists of 2 uncore caches.
40+
Each uncore cache serves 8 CPU cores.
41+
![Table showing CPU-to-CPU latency figures](./c2c_latency.png)
42+
Blue entries in the matrix represent latency between CPUs sharing the same uncore cache, while grey entries indicate latency between CPUs corresponding to different uncore caches. Latency between CPUs that correspond to different caches are higher than the latency between CPUs that belong to the same cache.
43+
44+
With `prefer-align-cpus-by-uncorecache` enabled, the
45+
[static CPU Manager](/docs/concepts/policy/node-resource-managers/#static-policy) attempts to allocates CPU resources for a container, such that all CPUs assigned to a container share the same uncore cache.
46+
This policy operates on a best-effort basis, aiming to minimize the distribution of a container's CPU resources across uncore caches, based on the
47+
container's requirements, and accounting for allocatable resources on the node.
48+
49+
By running a workload, where it can, on a set of CPUS that use the smallest feasible number of uncore caches, applications benefit from reduced cache latency (as seen in the matrix above),
50+
and from reduced contention against other workloads, which can result in overall higher throughput.
51+
The benefit only shows up if your nodes use a split uncore cache topology for their processors.
52+
53+
The following diagram below illustrates uncore cache alignment when the feature is enabled.
54+
55+
![Diagram showing an example workload CPU assignment, default static policy, and with prefer-align-cpus-by-uncorecache](./cache-align-diagram.png)
56+
57+
By default, Kubernetes does not account for uncore cache topology; containers are assigned CPU resources using a packed methodology.
58+
As a result, Container 1 and Container 2 can experience a noisy neighbor impact due to
59+
cache access contention on Uncore Cache 0. Additionally, Container 2 will have CPUs distributed across both caches which can introduce a cross-cache latency.
60+
61+
With `prefer-align-cpus-by-uncorecache` enabled, each container is isolated on an individual cache. This resolves the cache contention between the containers and minimizes the cache latency for the CPUs being utilized.
62+
63+
## Use cases
64+
Common use cases can include telco applications like vRAN, Mobile Packet Core, and Firewalls. It's important to note that the optimization provided by `prefer-align-cpus-by-uncorecache` can be dependent on the workload. For example, applications that are memory bandwidth bound may not benefit from uncore cache alignment, as utilizing more uncore caches can increase memory bandwidth access.
65+
66+
## Enabling the feature
67+
To enable this feature, set the CPU Manager Policy to `static` and enable the CPU Manager Policy Options with `prefer-align-cpus-by-uncorecache`.
68+
69+
For Kubernetes 1.34, the feature is in the beta stage and requires the `CPUManagerPolicyBetaOptions`
70+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) to also be enabled.
71+
72+
Append the following to the kubelet configuration file:
73+
```yaml
74+
kind: KubeletConfiguration
75+
apiVersion: kubelet.config.k8s.io/v1beta1
76+
featureGates:
77+
...
78+
CPUManagerPolicyBetaOptions: true
79+
cpuManagerPolicy: "static"
80+
cpuManagerPolicyOptions:
81+
prefer-align-cpus-by-uncorecache: "true"
82+
reservedSystemCPUs: "0"
83+
...
84+
```
85+
86+
If you're making this change to an existing node, remove the `cpu_manager_state` file and then restart kubelet.
87+
88+
`prefer-align-cpus-by-uncorecache` can be enabled on nodes with a monolithic uncore cache processor. The feature will mimic a best-effort socket alignment effect and will pack CPU resources on the socket similar to the default static CPU Manager policy.
89+
90+
## Further reading
91+
See [Node Resource Managers](/docs/concepts/policy/node-resource-managers/) to learn more about the CPU Manager and the available policies.
92+
93+
Reference the documentation for `prefer-align-cpus-by-uncorecache` [here](/docs/concepts/policy/node-resource-managers/#prefer-align-cpus-by-uncorecache).
94+
95+
Please see the [Kubernetes Enhancement Proposal](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/4800-cpumanager-split-uncorecache) for more information on how `prefer-align-cpus-by-uncorecache` is implemented.
96+
97+
## Getting involved
98+
This feature is driven by [SIG Node](https://github.com/Kubernetes/community/blob/master/sig-node/README.md). If you are interested in helping develop this feature, sharing feedback, or participating in any other ongoing SIG Node projects, please attend the SIG Node meeting for more details.
252 KB
Loading

0 commit comments

Comments
 (0)