Skip to content

Commit

Permalink
Merge pull request #704 from nightmeng/dev/fix-cpu-request
Browse files Browse the repository at this point in the history
fix(qrm): fix cpu admit failed caused by float ceil
  • Loading branch information
luomingmeng authored Oct 12, 2024
2 parents 56ba904 + 1f93cf4 commit fd1b8d6
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: ## Run go test against code.
go test -v -coverprofile=coverage.txt -parallel=16 -p=16 -covermode=atomic -race -coverpkg=./... \
go test -v -json -coverprofile=coverage.txt -parallel=16 -p=16 -covermode=atomic -race -coverpkg=./... \
`go list ./pkg/... | grep -E -v "pkg/scheduler|pkg/controller/resource-recommend|pkg/util/resource-recommend"`

.PHONY: license
Expand Down
21 changes: 13 additions & 8 deletions cmd/katalyst-agent/app/options/qrm/memory_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import (
)

type MemoryOptions struct {
PolicyName string
ReservedMemoryGB uint64
SkipMemoryStateCorruption bool
EnableSettingMemoryMigrate bool
EnableMemoryAdvisor bool
ExtraControlKnobConfigFile string
EnableOOMPriority bool
OOMPriorityPinnedMapAbsPath string
PolicyName string
ReservedMemoryGB uint64
SkipMemoryStateCorruption bool
EnableSettingMemoryMigrate bool
EnableMemoryAdvisor bool
ExtraControlKnobConfigFile string
EnableOOMPriority bool
OOMPriorityPinnedMapAbsPath string
EnableNonBindingShareCoresMemoryResourceCheck bool

SockMemOptions
LogCacheOptions
Expand Down Expand Up @@ -71,6 +72,7 @@ func NewMemoryOptions() *MemoryOptions {
EnableSettingMemoryMigrate: false,
EnableMemoryAdvisor: false,
EnableOOMPriority: false,
EnableNonBindingShareCoresMemoryResourceCheck: true,
SockMemOptions: SockMemOptions{
EnableSettingSockMem: false,
SetGlobalTCPMemRatio: 20, // default: 20% * {host total memory}
Expand Down Expand Up @@ -105,6 +107,8 @@ func (o *MemoryOptions) AddFlags(fss *cliflag.NamedFlagSets) {
o.ExtraControlKnobConfigFile, "the absolute path of extra control knob config file")
fs.BoolVar(&o.EnableOOMPriority, "enable-oom-priority",
o.EnableOOMPriority, "if set true, we will enable oom priority enhancement")
fs.BoolVar(&o.EnableNonBindingShareCoresMemoryResourceCheck, "enable-non-binding-share-cores-memory-resource-check",
o.EnableNonBindingShareCoresMemoryResourceCheck, "enable the topology check for non-binding shares cores pods")
fs.StringVar(&o.OOMPriorityPinnedMapAbsPath, "oom-priority-pinned-bpf-map-path",
o.OOMPriorityPinnedMapAbsPath, "the absolute path of oom priority pinned bpf map")
fs.BoolVar(&o.EnableSettingSockMem, "enable-setting-sockmem",
Expand Down Expand Up @@ -137,6 +141,7 @@ func (o *MemoryOptions) ApplyTo(conf *qrmconfig.MemoryQRMPluginConfig) error {
conf.EnableMemoryAdvisor = o.EnableMemoryAdvisor
conf.ExtraControlKnobConfigFile = o.ExtraControlKnobConfigFile
conf.EnableOOMPriority = o.EnableOOMPriority
conf.EnableNonBindingShareCoresMemoryResourceCheck = o.EnableNonBindingShareCoresMemoryResourceCheck
conf.OOMPriorityPinnedMapAbsPath = o.OOMPriorityPinnedMapAbsPath
conf.EnableSettingSockMem = o.EnableSettingSockMem
conf.SetGlobalTCPMemRatio = o.SetGlobalTCPMemRatio
Expand Down
8 changes: 4 additions & 4 deletions pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ func (p *DynamicPolicy) getContainerRequestedCores(allocationInfo *state.Allocat
return allocationInfo.RequestQuantity
}

func (p *DynamicPolicy) checkNormalShareCoresCpuResource(req *pluginapi.ResourceRequest) (bool, error) {
func (p *DynamicPolicy) checkNonBindingShareCoresCpuResource(req *pluginapi.ResourceRequest) (bool, error) {
_, reqFloat64, err := util.GetPodAggregatedRequestResource(req)
if err != nil {
return false, fmt.Errorf("GetQuantityFromResourceReq failed with error: %v", err)
Expand All @@ -1186,14 +1186,14 @@ func (p *DynamicPolicy) checkNormalShareCoresCpuResource(req *pluginapi.Resource
state.WrapAllocationMetaFilter((*commonstate.AllocationMeta).CheckDedicated),
state.WrapAllocationMetaFilter((*commonstate.AllocationMeta).CheckSharedOrDedicatedNUMABinding))

general.Infof("[checkNormalShareCoresCpuResource] node cpu allocated: %d, allocatable: %d", shareCoresAllocatedInt, pooledCPUs.Size())
general.Infof("[checkNonBindingShareCoresCpuResource] node cpu allocated: %d, allocatable: %d", shareCoresAllocatedInt, pooledCPUs.Size())
if shareCoresAllocatedInt > pooledCPUs.Size() {
general.Warningf("[checkNormalShareCoresCpuResource] no enough cpu resource for normal share cores pod: %s/%s, container: %s (request: %.02f, node allocated: %d, node allocatable: %d)",
general.Warningf("[checkNonBindingShareCoresCpuResource] no enough cpu resource for non-binding share cores pod: %s/%s, container: %s (request: %.02f, node allocated: %d, node allocatable: %d)",
req.PodNamespace, req.PodName, req.ContainerName, reqFloat64, shareCoresAllocatedInt, pooledCPUs.Size())
return false, nil
}

general.InfoS("checkNormalShareCoresCpuResource memory successfully",
general.InfoS("checkNonBindingShareCoresCpuResource memory successfully",
"podNamespace", req.PodNamespace,
"podName", req.PodName,
"containerName", req.ContainerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ func (p *DynamicPolicy) applyBlocks(blockCPUSet advisorapi.BlockCPUSet, resp *ad
if allocationInfo.CheckSharedNUMABinding() {
poolEntry.QoSLevel = apiconsts.PodAnnotationQoSLevelSharedCores
// set SharedNUMABinding declarations to pool entry containing SharedNUMABinding containers,
// in order to differentiate them from normal share pools during GetFilteredPoolsCPUSetMap.
// in order to differentiate them from non-binding share cores pools during GetFilteredPoolsCPUSetMap.
poolEntry.Annotations = general.MergeMap(poolEntry.Annotations, map[string]string{
apiconsts.PodAnnotationMemoryEnhancementNumaBinding: apiconsts.PodAnnotationMemoryEnhancementNumaBindingEnable,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ func (p *DynamicPolicy) calcPoolResizeRequest(originAllocation, allocation *stat
allocation.PodNamespace, allocation.PodName, allocation.ContainerName, originPodAggregatedRequest, podAggregatedRequest)
}

// only support normal share and snb inplace update resize now
// only support share cores inplace update resize now (include non-binding share cores and share cores with NUMA binding)
if allocation.CheckSharedNUMABinding() {
// check snb numa migrate for inplace update resize
originTargetNumaID, err := state.GetSharedNUMABindingTargetNuma(originAllocation)
Expand Down Expand Up @@ -1136,7 +1136,7 @@ func (p *DynamicPolicy) applyPoolsAndIsolatedInfo(poolsCPUSet map[string]machine
if allocationInfo.CheckSharedNUMABinding() {
poolEntry.QoSLevel = apiconsts.PodAnnotationQoSLevelSharedCores
// set SharedNUMABinding declarations to pool entry containing SharedNUMABinding containers,
// in order to differentiate them from normal share pools during GetFilteredPoolsCPUSetMap.
// in order to differentiate them from non-binding share cores pools during GetFilteredPoolsCPUSetMap.
poolEntry.Annotations = general.MergeMap(poolEntry.Annotations, map[string]string{
apiconsts.PodAnnotationMemoryEnhancementNumaBinding: apiconsts.PodAnnotationMemoryEnhancementNumaBindingEnable,
})
Expand Down
Loading

0 comments on commit fd1b8d6

Please sign in to comment.