Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Accepted the suggested changes and commited.

Co-authored-by: Marco Voelz <voelzmo@users.noreply.github.com>
  • Loading branch information
navinjoy and voelzmo authored Dec 5, 2022
1 parent 94138cf commit 06e01ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions vertical-pod-autoscaler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,11 @@ Please note the usage of the following arguments to override default names and p
You can then choose which recommender to use by setting `recommenders` inside the `VerticalPodAutoscaler` spec.
### Override default values when OOM occurs
The below parameters can be used to overwrite the default values when an OOM event is occurred. When VPA observes an OOM it will use a sample that higher of:
`oom-bump-up-ratio` specifies times the memory usage observed during OOM.
`oom-min-bump-up-bytes` specifies minimal increase of memory after observing OOM.
### Custom memory bump-up after OOMKill
After an OOMKill event was observed, VPA increases the memory recommendation based on the observed memory usage in the event according to this formula: `recommendation = memory-usage-in-oomkill-event + max(oom-min-bump-up-bytes, memory-usage-in-oomkill-event * oom-bump-up-ratio)`.
You can configure the minimum bump-up as well as the multiplier by specifying startup arguments for the recommender:
`oom-bump-up-ratio` specifies the memory bump up ratio when OOM occurred, default is `1.2`. This means, memory will be increased by 20% after an OOMKill event.
`oom-min-bump-up-bytes` specifies minimal increase of memory after observing OOM. Defaults to `100 * 1024 * 1024` (=100MiB)
Usage in recommender deployment
```
Expand Down
4 changes: 2 additions & 2 deletions vertical-pod-autoscaler/pkg/recommender/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ var (
memoryAggregationIntervalCount = flag.Int64("memory-aggregation-interval-count", model.DefaultMemoryAggregationIntervalCount, `The number of consecutive memory-aggregation-intervals which make up the MemoryAggregationWindowLength which in turn is the period for memory usage aggregation by VPA. In other words, MemoryAggregationWindowLength = memory-aggregation-interval * memory-aggregation-interval-count.`)
memoryHistogramDecayHalfLife = flag.Duration("memory-histogram-decay-half-life", model.DefaultMemoryHistogramDecayHalfLife, `The amount of time it takes a historical memory usage sample to lose half of its weight. In other words, a fresh usage sample is twice as 'important' as one with age equal to the half life period.`)
cpuHistogramDecayHalfLife = flag.Duration("cpu-histogram-decay-half-life", model.DefaultCPUHistogramDecayHalfLife, `The amount of time it takes a historical CPU usage sample to lose half of its weight.`)
oomBumpUpRatio = flag.Float64("oom-bump-up-ratio", model.DefaultOOMBumpUpRatio, `The bump up ratio when OOM occurred, default is 1.2`)
oomMinBumpUp = flag.Float64("oom-min-bump-up-bytes", model.DefaultOOMMinBumpUp, `Specifies minimal increase of memory after observing OOM., default is 100 * 1024 * 1024`)
oomBumpUpRatio = flag.Float64("oom-bump-up-ratio", model.DefaultOOMBumpUpRatio, `The memory bump up ratio when OOM occurred, default is 1.2.`)
oomMinBumpUp = flag.Float64("oom-min-bump-up-bytes", model.DefaultOOMMinBumpUp, `The minimal increase of memory when OOM occurred in bytes, default is 100 * 1024 * 1024`)
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ type AggregationsConfig struct {
// CPUHistogramDecayHalfLife is the amount of time it takes a historical
// CPU usage sample to lose half of its weight.
CPUHistogramDecayHalfLife time.Duration
// OOMBumpUpRatio specifies how much memory will be added after observing OOM.
// OOMBumpUpRatio specifies the memory bump up ratio when OOM occurred.
OOMBumpUpRatio float64
// OOMMinBumpUp specifies minimal increase of memory after observing OOM.
// OOMMinBumpUp specifies the minimal increase of memory when OOM occurred in bytes.
OOMMinBumpUp float64
}

Expand All @@ -75,10 +75,10 @@ const (
// DefaultCPUHistogramDecayHalfLife is the default value for CPUHistogramDecayHalfLife.
// CPU usage sample to lose half of its weight.
DefaultCPUHistogramDecayHalfLife = time.Hour * 24
// DefaultOOMBumpUpRatio specifies how much memory will be added after observing OOM.
DefaultOOMBumpUpRatio float64 = 1.2
// DefaultOOMMinBumpUp specifies minimal increase of memory after observing OOM.
DefaultOOMMinBumpUp float64 = 100 * 1024 * 1024 // 100MB
// DefaultOOMBumpUpRatio is the default value for OOMBumpUpRatio.
DefaultOOMBumpUpRatio float64 = 1.2 // Memory is increased by 20% after an OOMKill.
// DefaultOOMMinBumpUp is the default value for OOMMinBumpUp.
DefaultOOMMinBumpUp float64 = 100 * 1024 * 1024 // Memory is increased by at least 100MB after an OOMKill.
)

// GetMemoryAggregationWindowLength returns the total length of the memory usage history aggregated by VPA.
Expand Down

0 comments on commit 06e01ac

Please sign in to comment.