Skip to content

Commit

Permalink
qrm supports shared_cores with numa binding hint optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
luomingmeng committed Dec 19, 2024
1 parent 9b501ce commit b5c430d
Show file tree
Hide file tree
Showing 15 changed files with 1,154 additions and 26 deletions.
35 changes: 28 additions & 7 deletions cmd/katalyst-agent/app/options/qrm/cpu_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ limitations under the License.
package qrm

import (
v1 "k8s.io/api/core/v1"
cliflag "k8s.io/component-base/cli/flag"

"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/commonstate"
cpuconsts "github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/cpu/consts"
qrmconfig "github.com/kubewharf/katalyst-core/pkg/config/agent/qrm"
"github.com/kubewharf/katalyst-core/pkg/util/native"
)

type CPUOptions struct {
Expand All @@ -34,20 +36,26 @@ type CPUOptions struct {
}

type CPUDynamicPolicyOptions struct {
EnableCPUAdvisor bool
EnableCPUPressureEviction bool
LoadPressureEvictionSkipPools []string
EnableSyncingCPUIdle bool
EnableCPUIdle bool
CPUNUMAHintPreferPolicy string
CPUNUMAHintPreferLowThreshold float64
EnableCPUAdvisor bool
EnableCPUPressureEviction bool
LoadPressureEvictionSkipPools []string
EnableSyncingCPUIdle bool
EnableCPUIdle bool
CPUNUMAHintPreferPolicy string
CPUNUMAHintPreferLowThreshold float64
EnableSharedCoresNUMABindingHintOptimizer bool
SharedCoresNUMABindingHintOptimizerOptions ServiceProfileHintOptimizerOptions
}

type CPUNativePolicyOptions struct {
EnableFullPhysicalCPUsOnly bool
CPUAllocationOption string
}

type ServiceProfileHintOptimizerOptions struct {
ResourceWeights native.ResourceThreshold
}

func NewCPUOptions() *CPUOptions {
return &CPUOptions{
PolicyName: "dynamic",
Expand All @@ -65,6 +73,13 @@ func NewCPUOptions() *CPUOptions {
commonstate.PoolNameFallback,
commonstate.PoolNameReserve,
},
EnableSharedCoresNUMABindingHintOptimizer: false,
SharedCoresNUMABindingHintOptimizerOptions: ServiceProfileHintOptimizerOptions{
ResourceWeights: native.ResourceThreshold{
v1.ResourceCPU: 1.,
v1.ResourceMemory: 1.,
},
},
},
CPUNativePolicyOptions: CPUNativePolicyOptions{
EnableFullPhysicalCPUsOnly: false,
Expand Down Expand Up @@ -103,6 +118,10 @@ func (o *CPUOptions) AddFlags(fss *cliflag.NamedFlagSets) {
fs.BoolVar(&o.EnableFullPhysicalCPUsOnly, "enable-full-physical-cpus-only",
o.EnableFullPhysicalCPUsOnly, "if set true, we will enable extra allocation restrictions to "+
"avoid different containers to possibly end up on the same core.")
fs.BoolVar(&o.EnableSharedCoresNUMABindingHintOptimizer, "enable-shared-cores-numa-binding-hint-optimizer",
o.EnableSharedCoresNUMABindingHintOptimizer, "if set true, we will enable shared cores numa binding hint optimizer")
fs.Var(&o.SharedCoresNUMABindingHintOptimizerOptions.ResourceWeights, "shared-cores-numa-binding-hint-optimizer-resource-weights",
"it indicates resource weights for shared cores numa binding hint optimizer")
}

func (o *CPUOptions) ApplyTo(conf *qrmconfig.CPUQRMPluginConfig) error {
Expand All @@ -118,5 +137,7 @@ func (o *CPUOptions) ApplyTo(conf *qrmconfig.CPUQRMPluginConfig) error {
conf.CPUAllocationOption = o.CPUAllocationOption
conf.CPUNUMAHintPreferPolicy = o.CPUNUMAHintPreferPolicy
conf.CPUNUMAHintPreferLowThreshold = o.CPUNUMAHintPreferLowThreshold
conf.EnableSharedCoresNUMABindingHintOptimizer = o.EnableSharedCoresNUMABindingHintOptimizer
conf.SharedCoresNUMABindingHintOptimizerConfig.ResourceWeights = o.SharedCoresNUMABindingHintOptimizerOptions.ResourceWeights
return nil
}
33 changes: 33 additions & 0 deletions pkg/agent/qrm-plugins/cpu/dynamicpolicy/hintoptimizer/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2022 The Katalyst Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hintoptimizer

import (
pluginapi "k8s.io/kubelet/pkg/apis/resourceplugin/v1alpha1"

"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state"
)

type HintOptimizer interface {
OptimizeHints(*pluginapi.ResourceRequest, []*pluginapi.TopologyHint, state.NUMANodeMap) error
}

type DummyHintOptimizer struct{}

func (d *DummyHintOptimizer) OptimizeHints(*pluginapi.ResourceRequest, []*pluginapi.TopologyHint, state.NUMANodeMap) error {
return nil
}
Loading

0 comments on commit b5c430d

Please sign in to comment.