Documentation ¶
Index ¶
- Constants
- Variables
- func NewFileCheckpointer(path string) *fileCheckpointer
- type Checkpointer
- type Config
- type Informer
- type MetricDesc
- type MetricKey
- type MetricServer
- type ModelCheckpoint
- type NodeItemsUsage
- type Options
- type PredictMetric
- type PredictModel
- type PredictServer
- type Predictor
- type PredictorFactory
- type PredictorType
- type Result
- type UIDGenerator
- type UIDType
Constants ¶
const ( DefaultNodeID = "__node__" DefaultNodeItemIDFmt = "__node-%s__" SystemItemID = "sys" // node item ID for the system overhead which is not counted in any pod AllPodsItemID = "all-pods" // not stored for now, just used for calculating the sys )
const (
TmpFileSuffix = ".tmp"
)
Variables ¶
var ( // MinSampleWeight is the minimal weight of any sample (prior to including decaying factor) MinSampleWeight = 0.1 // DefaultHistogramBucketSizeGrowth is the default value for histogramBucketSizeGrowth. DefaultHistogramBucketSizeGrowth = 0.05 )
Functions ¶
func NewFileCheckpointer ¶
func NewFileCheckpointer(path string) *fileCheckpointer
NewFileCheckpointer creates a new file-based checkpointer with the specified directory.
Types ¶
type Checkpointer ¶
type Checkpointer interface { Save(checkpoint ModelCheckpoint) error Remove(UID UIDType) error Restore() ([]*ModelCheckpoint, error) }
Checkpointer is an interface for saving and restoring model checkpoints.
type Config ¶
type Config struct { CheckpointFilepath string ColdStartDuration time.Duration SafetyMarginPercent int MemoryHistogramDecayHalfLife time.Duration CPUHistogramDecayHalfLife time.Duration TrainingInterval time.Duration ModelExpirationDuration time.Duration ModelCheckpointInterval time.Duration ModelCheckpointMaxPerStep int }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type Informer ¶
FIXME This is used for the agent's dependence on the basic data structure, and the basic data structure will be reconstructed later to better support testing.
func NewInformer ¶
func NewInformer(statesInformer statesinformer.StatesInformer) Informer
type MetricDesc ¶
type MetricDesc struct {
UID UIDType
}
type MetricServer ¶
type MetricServer interface { GetPodMetric(desc MetricDesc, m MetricKey) (float64, error) GetNodeMetric(desc MetricDesc, m MetricKey) (float64, error) }
func NewMetricServer ¶
func NewMetricServer(metricCache metriccache.MetricCache, dataInterval time.Duration) MetricServer
type ModelCheckpoint ¶
type ModelCheckpoint struct { UID UIDType CPU *histogram.HistogramCheckpoint Memory *histogram.HistogramCheckpoint LastUpdated metav1.Time Error error `json:"-,omitempty"` }
ModelCheckpoint represents a checkpoint for a model.
type NodeItemsUsage ¶
type NodeItemsUsage struct { // MetricMap maps an item to its predict metric. // e.g. // PriorityProd -> {6.2 cores, 20 GiB} // sys -> {0.1 cores, 4 GiB} MetricMap map[string]*PredictMetric }
func NewNodeItemUsage ¶
func NewNodeItemUsage() *NodeItemsUsage
func (*NodeItemsUsage) AddMetric ¶
func (m *NodeItemsUsage) AddMetric(itemID string, cpuUsage, memoryUsage float64)
func (*NodeItemsUsage) GetMetric ¶
func (m *NodeItemsUsage) GetMetric(itemID string) (*PredictMetric, bool)
type PredictMetric ¶
type PredictModel ¶
type PredictServer ¶
type PredictServer interface { Setup(statesinformer.StatesInformer, metriccache.MetricCache) error Run(stopCh <-chan struct{}) error HasSynced() bool GetPrediction(MetricDesc) (Result, error) }
PredictServer is responsible for fetching data from MetricCache, training prediction results according to predefined models, and providing an interface for obtaining prediction results.
It is important to note that the prediction results made by PredictServer based on the captured data are only related to the data it sees. For example, when we need to deal with cold starts, this business logic should be processed when using the predicted data instead of being coupled to the predictive model.
The predictive model currently provides histogram-based statistics with exponentially decaying weights over time periods. PredictServer is responsible for storing the intermediate results of the model and recovering when the process restarts.
func NewPeakPredictServer ¶
func NewPeakPredictServer(cfg *Config) PredictServer
type PredictorFactory ¶
type PredictorFactory interface {
New(PredictorType) Predictor
}
PredictorFactory is an interface for creating predictors of different types.
func NewEmptyPredictorFactory ¶
func NewEmptyPredictorFactory() PredictorFactory
func NewPredictorFactory ¶
func NewPredictorFactory(predictServer PredictServer, coldStartDuration time.Duration, safetyMarginPercent int) PredictorFactory
NewPredictorFactory creates a new instance of PredictorFactory.
type PredictorType ¶
type PredictorType int
PredictorType defines constants for different types of predictors.
const ( // ProdReclaimablePredictor represents the type of a reclaimable production predictor. ProdReclaimablePredictor PredictorType = iota )
type Result ¶
type Result struct { // Use different quantile type as key, currently support "p60", "p90", "p95" "p98", "max". Data map[string]v1.ResourceList }