Memory Manager Goals
-
保证最少 NUMA Node 去满足 POD 的内存需求: Offer guaranteed memory (and hugepages) allocation over a minimum number of NUMA nodes for containers (within a pod).
-
长远是让pod中的所有 container 运行在尽量少的 NUMA NODE 中: Guaranteeing the affinity of memory and hugepages to the same NUMA node for the whole group of containers (within a pod). This is a long-term goal which will be achieved along with PR #1752 and the implementation of
hintprovider.GetPodLevelTopologyHints()
API in the Memory Manager.- Offer guaranteed memory (and hugepages) allocation over a minimum number of NUMA nodes for containers (within a pod).
Design Overview
Once kubelet requests a guaranteed QoS pod admission, as shown in the figure above, Topology Manager queries Memory Manager about the preferred NUMA affinity for memory and hugepages, for all containers in a pod. For each container in a pod, Memory Manager calculates the affinity using its internal database, namely the Node Map
. The Node Map
is an object which is responsible for tracking the utilization of memory (and hugepages) for all containers in Guaranteed QoS class. Once Memory Manager completes the computations, it returns the hints to Topology Manager so that Topology Manager can figure out which NUMA node or a group of NUMA nodes are the best fit for memory pinning, for a container. The overall calculation is performed for all containers in the pod, and if none of containers is rejected, the pod becomes finally admitted and deployed(只有所有 Container 都通过时,才能通过 Admit).
Design Details
|
|
每个 NUMA_Node + pageSize 组合对应一个 MemoryTable
。数值之间的关系:
Allocatable = TotalMemSize - SystemReserved
Free + Reserved = Allocatable
例如:
--reserved-memory={numa-node=0, type=memory, limit=500MB}, {numa-node=1,type=memory, limit=100MB}