From 2cbbb558dd3db12b88fdacd79c182d1d56110687 Mon Sep 17 00:00:00 2001 From: "zhangyadong.0808" Date: Mon, 13 Jan 2025 18:08:17 +0800 Subject: [PATCH] set min reclaim pool size for multi region --- .../provisionassembler/assembler_common.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/assembler/provisionassembler/assembler_common.go b/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/assembler/provisionassembler/assembler_common.go index 9ceec834c..38f9f05fa 100644 --- a/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/assembler/provisionassembler/assembler_common.go +++ b/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/assembler/provisionassembler/assembler_common.go @@ -19,6 +19,8 @@ package provisionassembler import ( "fmt" "math" + "os" + "strconv" "time" "k8s.io/klog/v2" @@ -35,6 +37,16 @@ import ( "github.com/kubewharf/katalyst-core/pkg/util/machine" ) +var defaultMinReclaimPoolSize = 8 + +func init() { + if value := os.Getenv("MIN_RECLAIM_POOLSIZE"); value == "" { + if size, err := strconv.Atoi(value); err == nil && size > defaultMinReclaimPoolSize { + defaultMinReclaimPoolSize = size + } + } +} + type ProvisionAssemblerCommon struct { conf *config.Configuration regionMap *map[string]region.QoSRegion @@ -293,6 +305,23 @@ func (pa *ProvisionAssemblerCommon) AssembleProvision() (types.InternalCPUCalcul } } reclaimPoolSizeOfNonBindingNUMAs = general.SumUpMapValues(sharedOverlapReclaimSize) + + if reclaimPoolSizeOfNonBindingNUMAs < defaultMinReclaimPoolSize { + newSharedOverlapReclaimSize, err := regulateOverlapReclaimPoolSize(sharePoolSizes, defaultMinReclaimPoolSize) + if err != nil { + klog.ErrorS(err, "calculate pool size is too low, fall back to ratio policy failed", + "share pool size", sharePoolSizes, + "min reclaim pool size", defaultMinReclaimPoolSize, + "old reclaim pool", sharedOverlapReclaimSize) + } else { + klog.InfoS("calculate pool size is too low, fall back to ratio policy", + "share pool size", sharePoolSizes, + "min reclaim pool size", defaultMinReclaimPoolSize, + "old reclaim pool", sharedOverlapReclaimSize, "new reclaim pool", newSharedOverlapReclaimSize) + sharedOverlapReclaimSize = newSharedOverlapReclaimSize + reclaimPoolSizeOfNonBindingNUMAs = general.SumUpMapValues(sharedOverlapReclaimSize) + } + } } for overlapPoolName, size := range sharedOverlapReclaimSize {