github.com/kubewharf/katalyst-core@v0.5.3/cmd/katalyst-agent/app/options/qrm/io_plugin.go (about) 1 /* 2 Copyright 2022 The Katalyst Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package qrm 18 19 import ( 20 cliflag "k8s.io/component-base/cli/flag" 21 22 qrmconfig "github.com/kubewharf/katalyst-core/pkg/config/agent/qrm" 23 ) 24 25 type IOOptions struct { 26 PolicyName string 27 28 WritebackThrottlingOption // option for writeback throttling, it determin the recycling speed of dirty memory. 29 // TO-DO 30 // DirtyThrottlingOption // option for dirty throttling, it determin the global watermark of dirty memory. 31 IOCostOption 32 IOWeightOption 33 } 34 35 type WritebackThrottlingOption struct { 36 EnableSettingWBT bool 37 WBTValueHDD int 38 WBTValueSSD int 39 WBTValueNVME int 40 } 41 42 type IOCostOption struct { 43 EnableSettingIOCost bool 44 IOCostQoSConfigFile string 45 IOCostModelConfigFile string 46 } 47 48 type IOWeightOption struct { 49 EnableSettingIOWeight bool 50 IOWeightQoSLevelConfigFile string 51 IOWeightCgroupLevelConfigFile string 52 } 53 54 func NewIOOptions() *IOOptions { 55 return &IOOptions{ 56 PolicyName: "static", 57 WritebackThrottlingOption: WritebackThrottlingOption{ 58 EnableSettingWBT: false, 59 WBTValueHDD: 75000, 60 WBTValueSSD: 2000, 61 WBTValueNVME: 2000, 62 }, 63 IOCostOption: IOCostOption{ 64 EnableSettingIOCost: false, 65 IOCostQoSConfigFile: "", 66 IOCostModelConfigFile: "", 67 }, 68 IOWeightOption: IOWeightOption{ 69 EnableSettingIOWeight: false, 70 IOWeightQoSLevelConfigFile: "", 71 IOWeightCgroupLevelConfigFile: "", 72 }, 73 } 74 } 75 76 func (o *IOOptions) AddFlags(fss *cliflag.NamedFlagSets) { 77 fs := fss.FlagSet("io_resource_plugin") 78 79 fs.StringVar(&o.PolicyName, "io-resource-plugin-policy", 80 o.PolicyName, "The policy io resource plugin should use") 81 fs.BoolVar(&o.EnableSettingWBT, "enable-disk-wbt", 82 o.EnableSettingWBT, "if set it to true, disk wbt related control operations will be executed") 83 fs.IntVar(&o.WBTValueHDD, "disk-wbt-hdd", 84 o.WBTValueHDD, "writeback throttling value for HDD") 85 fs.IntVar(&o.WBTValueSSD, "disk-wbt-ssd", 86 o.WBTValueSSD, "writeback throttling value for SSD") 87 fs.IntVar(&o.WBTValueNVME, "disk-wbt-nvme", 88 o.WBTValueNVME, "writeback throttling value for NVME") 89 fs.BoolVar(&o.EnableSettingIOCost, "enable-io-cost", 90 o.EnableSettingIOCost, "if set it to true, io.cost setting will be executed") 91 fs.StringVar(&o.IOCostQoSConfigFile, "io-cost-qos-config-file", 92 o.IOCostQoSConfigFile, "the absolute path of io.cost.qos qos config file") 93 fs.StringVar(&o.IOCostModelConfigFile, "io-cost-model-config-file", 94 o.IOCostModelConfigFile, "the absolute path of io.cost.model qos config file") 95 fs.BoolVar(&o.EnableSettingIOWeight, "enable-io-weight", 96 o.EnableSettingIOWeight, "if set it to true, io.weight related control operations will be executed") 97 fs.StringVar(&o.IOWeightQoSLevelConfigFile, "io-weight-qos-config-file", 98 o.IOWeightQoSLevelConfigFile, "the absolute path of io.weight qos config file") 99 fs.StringVar(&o.IOWeightCgroupLevelConfigFile, "io-weight-cgroup-config-file", 100 o.IOWeightCgroupLevelConfigFile, "the absolute path of io.weight cgroup config file") 101 } 102 103 func (o *IOOptions) ApplyTo(conf *qrmconfig.IOQRMPluginConfig) error { 104 conf.PolicyName = o.PolicyName 105 conf.EnableSettingWBT = o.EnableSettingWBT 106 conf.WBTValueHDD = o.WBTValueHDD 107 conf.WBTValueSSD = o.WBTValueSSD 108 conf.WBTValueNVME = o.WBTValueNVME 109 conf.EnableSettingIOCost = o.EnableSettingIOCost 110 conf.IOCostQoSConfigFile = o.IOCostQoSConfigFile 111 conf.IOCostModelConfigFile = o.IOCostModelConfigFile 112 conf.EnableSettingIOWeight = o.EnableSettingIOWeight 113 conf.IOWeightQoSLevelConfigFile = o.IOWeightQoSLevelConfigFile 114 conf.IOWeightCgroupLevelConfigFile = o.IOWeightCgroupLevelConfigFile 115 return nil 116 }