-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memory headroom canonical policy support enable buffer
- Loading branch information
1 parent
e1ac91b
commit b30f177
Showing
12 changed files
with
1,020 additions
and
87 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
cmd/katalyst-agent/app/options/sysadvisor/qosaware/resource/memory/headroom/policy_base.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
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 headroom | ||
|
||
import ( | ||
"github.com/spf13/pflag" | ||
"k8s.io/apimachinery/pkg/util/errors" | ||
|
||
"github.com/kubewharf/katalyst-core/pkg/config/agent/sysadvisor/qosaware/resource/memory/headroom" | ||
) | ||
|
||
type MemoryHeadroomPolicyOptions struct { | ||
MemoryPolicyCanonicalOptions *MemoryPolicyCanonicalOptions | ||
} | ||
|
||
func NewMemoryHeadroomPolicyOptions() *MemoryHeadroomPolicyOptions { | ||
return &MemoryHeadroomPolicyOptions{ | ||
MemoryPolicyCanonicalOptions: NewMemoryPolicyCanonicalOptions(), | ||
} | ||
} | ||
|
||
func (o *MemoryHeadroomPolicyOptions) AddFlags(fs *pflag.FlagSet) { | ||
o.MemoryPolicyCanonicalOptions.AddFlags(fs) | ||
} | ||
|
||
func (o *MemoryHeadroomPolicyOptions) ApplyTo(c *headroom.MemoryHeadroomPolicyConfiguration) error { | ||
var errList []error | ||
errList = append(errList, o.MemoryPolicyCanonicalOptions.ApplyTo(c.MemoryPolicyCanonicalConfiguration)) | ||
return errors.NewAggregate(errList) | ||
} |
85 changes: 85 additions & 0 deletions
85
...talyst-agent/app/options/sysadvisor/qosaware/resource/memory/headroom/policy_canonical.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
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 headroom | ||
|
||
import ( | ||
"github.com/spf13/pflag" | ||
|
||
"github.com/kubewharf/katalyst-core/pkg/config/agent/sysadvisor/qosaware/resource/memory/headroom" | ||
) | ||
|
||
const ( | ||
defaultEnabled = false | ||
defaultFreeBasedRatio = 0.6 | ||
defaultStaticBasedCapacity = 20 << 30 // 20GB | ||
|
||
defaultCacheBaseRatio = 0 | ||
defaultCPUMemRatioLowerBound = 1. / 6. | ||
defaultCPUMemRatioUpperBound = 1. / 3.5 | ||
) | ||
|
||
type MemoryPolicyCanonicalOptions struct { | ||
*MemoryUtilBasedOptions | ||
} | ||
|
||
type MemoryUtilBasedOptions struct { | ||
Enabled bool | ||
FreeBasedRatio float64 | ||
CacheBasedRatio float64 | ||
StaticBasedCapacity float64 | ||
|
||
CPUMemRatioLowerBound float64 | ||
CPUMemRatioUpperBound float64 | ||
} | ||
|
||
func NewMemoryPolicyCanonicalOptions() *MemoryPolicyCanonicalOptions { | ||
return &MemoryPolicyCanonicalOptions{ | ||
MemoryUtilBasedOptions: &MemoryUtilBasedOptions{ | ||
Enabled: defaultEnabled, | ||
FreeBasedRatio: defaultFreeBasedRatio, | ||
StaticBasedCapacity: defaultStaticBasedCapacity, | ||
CacheBasedRatio: defaultCacheBaseRatio, | ||
CPUMemRatioLowerBound: defaultCPUMemRatioLowerBound, | ||
CPUMemRatioUpperBound: defaultCPUMemRatioUpperBound, | ||
}, | ||
} | ||
} | ||
|
||
func (o *MemoryPolicyCanonicalOptions) AddFlags(fs *pflag.FlagSet) { | ||
fs.BoolVar(&o.Enabled, "memory-headroom-policy-canonical-util-based-enabled", o.Enabled, | ||
"the flag to enable memory buffer") | ||
fs.Float64Var(&o.FreeBasedRatio, "memory-headroom-policy-canonical-free-based-ratio", o.FreeBasedRatio, | ||
"the estimation of free memory utilization, which can be used as system buffer to oversold memory") | ||
fs.Float64Var(&o.StaticBasedCapacity, "memory-headroom-policy-canonical-static-based-capacity", o.StaticBasedCapacity, | ||
"the static oversold memory size by bytes") | ||
fs.Float64Var(&o.CacheBasedRatio, "memory-headroom-policy-canonical-cache-based-ratio", o.CacheBasedRatio, | ||
"the rate of cache oversold, 0 means disable cache oversold") | ||
fs.Float64Var(&o.CPUMemRatioLowerBound, "memory-headroom-policy-canonical-cpu-mem-ratio-lower-bound", o.CPUMemRatioLowerBound, | ||
"the upper bound of memory to cpu ratio for enabling cache oversold") | ||
fs.Float64Var(&o.CPUMemRatioUpperBound, "memory-headroom-policy-canonical-cpu-mem-ratio-upper-bound", o.CPUMemRatioUpperBound, | ||
"the lower bound of memory to cpu ratio for enabling cache oversold") | ||
} | ||
|
||
func (o *MemoryPolicyCanonicalOptions) ApplyTo(c *headroom.MemoryPolicyCanonicalConfiguration) error { | ||
c.Enabled = o.Enabled | ||
c.FreeBasedRatio = o.FreeBasedRatio | ||
c.StaticBasedCapacity = o.StaticBasedCapacity | ||
c.CacheBasedRatio = o.CacheBasedRatio | ||
c.CPUMemRatioLowerBound = o.CPUMemRatioLowerBound | ||
c.CPUMemRatioUpperBound = o.CPUMemRatioUpperBound | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.