Documentation
¶
Overview ¶
Package rightsizing is a deterministic, pure-Go engine that turns an app's historical CPU/memory usage into a resource-limit suggestion. It is a read-and-suggest layer on top of the platform API, per this project's AI design rule: it never calls an external model, never writes to any resource, and its output is never applied automatically. Every recommendation is backed by literal samples or a literal OOM signal it was given; when there isn't enough history yet, Recommend says so rather than guessing.
Index ¶
- Constants
- func FormatCPU(nanoCPUs int64) string
- func FormatMemory(bytes int64) string
- func HumanDuration(d time.Duration) string
- func HumanWindow(d time.Duration) string
- func RoundCPUUp(nanoCPUs float64) int64
- func RoundMemoryUp(bytes float64) int64
- type DimensionRecommendation
- type Input
- type OOMEvidence
- type Result
- type Sample
- type Tuning
Constants ¶
const ( ConfidenceHigh = "high" ConfidenceMedium = "medium" ConfidenceLow = "low" )
Confidence levels a DimensionRecommendation can carry.
const ( ActionRaise = "raise" ActionLower = "lower" ActionKeep = "keep" )
Actions a DimensionRecommendation can suggest.
Variables ¶
This section is empty.
Functions ¶
func FormatMemory ¶ added in v0.2.0
FormatMemory renders bytes as MiB or GiB.
func HumanDuration ¶ added in v0.2.0
HumanDuration renders a duration in whole days, hours or minutes.
func HumanWindow ¶ added in v0.2.0
HumanWindow renders a lookback as "last 7 days" rather than "168h0m0s".
func RoundCPUUp ¶ added in v0.2.0
RoundCPUUp rounds nano-CPUs up to the next suggested step, never below 0.1 core.
func RoundMemoryUp ¶ added in v0.2.0
RoundMemoryUp rounds a byte count up to the next suggested memory step.
Types ¶
type DimensionRecommendation ¶
type DimensionRecommendation struct {
Dimension string
SampleCount int
DataSufficient bool
Confidence string
CurrentLimit int64
P95Usage float64
P99Usage float64
SuggestedLimit int64
// Action is "" when there isn't enough data, or no limit is
// currently set, to responsibly suggest raising or lowering one.
Action string
Reason string
}
DimensionRecommendation is one resource dimension's (memory or CPU) suggestion.
type Input ¶
type Input struct {
ServiceName string
Now time.Time
LookbackWindow time.Duration
MemorySamples []Sample
CPUPercentSamples []Sample
CurrentMemoryBytes int64
CurrentNanoCPUs int64
OOM *OOMEvidence
// Tuning overrides the default thresholds; a zero field keeps its default.
Tuning Tuning
}
Input bundles one app's usage history and current limits. CPUPercentSamples is Docker's own 0-100-per-core convention (internal/docker.ContainerStats. CPUPercent's own doc comment): a container fully using 2 cores reads 200, converted internally to nano-CPUs to compare against CurrentNanoCPUs.
type OOMEvidence ¶
OOMEvidence is a genuinely observed OOM-kill signal (a log line matching a known OOM pattern; see internal/diagnose.OOMLogPatterns), never fabricated from usage numbers alone.
type Result ¶
type Result struct {
ServiceName string
LookbackWindow time.Duration
Memory DimensionRecommendation
CPU DimensionRecommendation
OOM *OOMEvidence
}
Result is Recommend's output: one recommendation per dimension, plus whatever OOM evidence fed into the memory one.