Open so-sahu opened 9 months ago
type ResourceName string
const (
ResourceCPU ResourceName = "cpu"
ResourceMemory ResourceName = "memory"
ResourceSGX ResourceName = "sgx"
ResourceHugepages ResourceName = "hugepages"
)
type MachineSpec struct {
...
Resources ResourceList
NumaNodes []int
CPUPins map[int]int
...
}
type ResourceList map[ResourceName]resource.Quantity
func (rl *ResourceList) Get(name ResourceName) resource.Quantity {
if val, ok := (*rl)[name]; ok {
return val
}
return resource.Quantity{}
}
func (rl *ResourceList) Set(name ResourceName, value resource.Quantity) {
(*rl)[name] = value
}
func (rl *ResourceList) CPU() resource.Quantity {
return rl.Get(ResourceCPU)
}
func (rl *ResourceList) Memory() resource.Quantity {
return rl.Get(ResourceMemory)
}
func (rl *ResourceList) SGX() resource.Quantity {
return rl.Get(ResourceSGX)
}
func (rl *ResourceList) EnableHugepages() bool{
if rl.Get(ResourceHugepages).Value() == 1 {
return true
}
return false
}
ResourceName and ResourceList Types
ResourceName
defines string constants for different types of resources (cpu
, memory
, sgx
, hugepages
).ResourceList
is a map that associates ResourceName
with resource.Quantity
to manage resource quantities.MachineSpec Struct
MachineSpec
struct now includes a Resources
field of type ResourceList
to store resource allocations.ResourceList Methods
Get(name ResourceName) resource.Quantity
: Retrieves the quantity of the specified resource.Set(name ResourceName, value resource.Quantity)
: Sets the quantity of the specified resource.CPU()
, Memory()
, SGX()
: Convenience methods to retrieve specific resource quantities.EnableHugepages()
: Checks if hugepages are enabled.Why do you need VCUAllocationRatio, BlockedHugepages and BlockedCPUs in machine spec? It is important for resource manager only for my point of view.
Do you need NumaDomain? Isn't it len(NumaNodes)?
network cards and storage can be resources too which ideally will manage by resource manager too. Could you think maybe how we can implement it too?
what do you think about use resource.Quantity type? https://github.com/ironcore-dev/ironcore/blob/main/api/core/v1alpha1/resource.go
How about the following. In the spec I have the possibility to assign a NUMA topoligy like this. If it is empty it is ignored (in case NUMA pinning is disabled) or a Scheduler/Resource Manager ensures that it is correctly filled later.
type MachineSpec struct {
// Existing fields...
NUMAPreferences NUMAPreferences `json:"numaPreferences,omitempty"`
}
type NUMAPreferences struct {
CPUNodes []int `json:"cpuNodes,omitempty"`
MemoryNodes []int `json:"memoryNodes,omitempty"`
IoNodes []int `json:"ioNodes,omitempty"`
}
And in the Status
you can update the information once the placement has been fulfilled.
type MachineStatus struct {
// Existing fields...
NUMAPlacement NUMAPlacement `json:"numaPlacement,omitempty"`
}
type NUMAPlacement struct {
CPUNodes []int `json:"cpuNodes"`
MemoryNodes []int `json:"memoryNodes"`
IoNodes []int `json:"ioNodes"`
}
Summary
This issue captures the efforts to extend the API machine object and the corresponding reconciler changes. The proposals and changes can be discussed in this issue.