optimization

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheKeyLLMResponse = "llm:response:%s" // intent hash

	CacheKeyRAGContext = "rag:context:%s" // query hash

	CacheKeyResourcePlan = "resource:plan:%s" // plan hash

	CacheKeyManifestTemplate = "manifest:template:%s" // template hash

	CacheKeyGitCommit = "git:commit:%s" // manifest hash

	CacheKeyDeploymentStatus = "deployment:status:%s" // deployment hash

	CacheKeyTelecomKnowledge = "telecom:knowledge:%s" // knowledge hash

)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheLevel

type CacheLevel int
const (
	L1CacheLevel CacheLevel = iota + 1 // In-memory local cache

	L2CacheLevel // Distributed Redis cache

	L3CacheLevel // Persistent storage cache

)

type CacheMetrics

type CacheMetrics struct {
	HitRate float64 `json:"hitRate"`

	MissRate float64 `json:"missRate"`

	EvictionRate float64 `json:"evictionRate"`

	SizeBytes int64 `json:"sizeBytes"`

	ItemCount int64 `json:"itemCount"`
}

type CacheMetricsCollector

type CacheMetricsCollector struct {
	// contains filtered or unexported fields
}

func NewCacheMetricsCollector

func NewCacheMetricsCollector() *CacheMetricsCollector

func (*CacheMetricsCollector) GetEvictionRate

func (c *CacheMetricsCollector) GetEvictionRate() float64

func (*CacheMetricsCollector) GetOverallHitRate

func (c *CacheMetricsCollector) GetOverallHitRate() float64

func (*CacheMetricsCollector) GetOverallMissRate

func (c *CacheMetricsCollector) GetOverallMissRate() float64

func (*CacheMetricsCollector) GetUsagePatterns

func (c *CacheMetricsCollector) GetUsagePatterns() *CacheUsagePatterns

func (*CacheMetricsCollector) RecordCacheHit

func (c *CacheMetricsCollector) RecordCacheHit(level CacheLevel, key string)

func (*CacheMetricsCollector) RecordCacheMiss

func (c *CacheMetricsCollector) RecordCacheMiss(level CacheLevel, key string)

func (*CacheMetricsCollector) RecordCacheSet

func (c *CacheMetricsCollector) RecordCacheSet(level CacheLevel, key string)

type CachePolicy

type CachePolicy struct {
	TTL time.Duration `json:"ttl"`

	MaxSize int64 `json:"maxSize"`

	EvictionPolicy EvictionPolicy `json:"evictionPolicy"`

	Levels []CacheLevel `json:"levels"`

	CompressionEnabled bool `json:"compressionEnabled"`

	PrefetchEnabled bool `json:"prefetchEnabled"`

	ReplicationFactor int `json:"replicationFactor"`
}

type CacheUsagePatterns

type CacheUsagePatterns struct {
	HotKeys []string `json:"hotKeys"`

	ColdKeys []string `json:"coldKeys"`

	AccessFrequency map[string]int `json:"accessFrequency"`

	AccessTimes map[string][]time.Time `json:"accessTimes"`

	EvictionPatterns map[string]EvictionPattern `json:"evictionPatterns"`
}

type CachingProfile

type CachingProfile struct {
	EnableL1Cache bool `json:"enableL1Cache"`

	EnableL2Cache bool `json:"enableL2Cache"`

	EnableL3Cache bool `json:"enableL3Cache"`

	TTLMultiplier float64 `json:"ttlMultiplier"`

	PrefetchEnabled bool `json:"prefetchEnabled"`

	CompressionEnabled bool `json:"compressionEnabled"`
}

type ConnectionMetrics

type ConnectionMetrics struct {
	TotalConnections int `json:"totalConnections"`

	ActiveConnections int `json:"activeConnections"`

	IdleConnections int `json:"idleConnections"`

	FailedConnections int `json:"failedConnections"`
}

type ConnectionPoolManager

type ConnectionPoolManager struct {
	// contains filtered or unexported fields
}

func NewConnectionPoolManager

func NewConnectionPoolManager(config *PerformanceConfig, logger logr.Logger) *ConnectionPoolManager

func (*ConnectionPoolManager) ApplyResourceProfile

func (cpm *ConnectionPoolManager) ApplyResourceProfile(profile ResourceProfile) error

func (*ConnectionPoolManager) Start

func (cpm *ConnectionPoolManager) Start(ctx context.Context) error

func (*ConnectionPoolManager) Stop

func (cpm *ConnectionPoolManager) Stop(ctx context.Context) error

type ControllerInstance

type ControllerInstance struct {
	ID string `json:"id"`

	Address string `json:"address"`

	Health string `json:"health"` // healthy, degraded, unhealthy

	CurrentLoad int `json:"currentLoad"`

	MaxCapacity int `json:"maxCapacity"`

	ProcessingPhases []interfaces.ProcessingPhase `json:"processingPhases"`

	AvgResponseTime time.Duration `json:"avgResponseTime"`

	ErrorRate float64 `json:"errorRate"`

	ThroughputRate float64 `json:"throughputRate"`
}

type DatabaseConnectionPool

type DatabaseConnectionPool struct {
	// contains filtered or unexported fields
}

func NewDatabaseConnectionPool

func NewDatabaseConnectionPool(name string, maxConns int, logger logr.Logger) *DatabaseConnectionPool

func (*DatabaseConnectionPool) Close

func (p *DatabaseConnectionPool) Close() error

type DiskIOMetrics

type DiskIOMetrics struct {
	BytesRead int64 `json:"bytesRead"`

	BytesWritten int64 `json:"bytesWritten"`

	IOPSRead int64 `json:"iopsRead"`

	IOPSWrite int64 `json:"iopsWrite"`
}

type EvictionPattern

type EvictionPattern struct {
	Key string `json:"key"`

	EvictionCount int `json:"evictionCount"`

	LastEviction time.Time `json:"lastEviction"`

	Reason string `json:"reason"`
}

type EvictionPolicy

type EvictionPolicy string
const (
	EvictionLRU EvictionPolicy = "lru"

	EvictionLFU EvictionPolicy = "lfu"

	EvictionFIFO EvictionPolicy = "fifo"

	EvictionTTL EvictionPolicy = "ttl"

	EvictionRandom EvictionPolicy = "random"
)

type HTTPConnectionPool

type HTTPConnectionPool struct {
	// contains filtered or unexported fields
}

func NewHTTPConnectionPool

func NewHTTPConnectionPool(name string, maxConns int, logger logr.Logger) *HTTPConnectionPool

func (*HTTPConnectionPool) Close

func (p *HTTPConnectionPool) Close() error

func (*HTTPConnectionPool) Resize

func (p *HTTPConnectionPool) Resize(newSize int)

type L1Cache

type L1Cache struct {
	// contains filtered or unexported fields
}

func NewL1Cache

func NewL1Cache(size int64, logger logr.Logger) *L1Cache

func (*L1Cache) Cleanup

func (c *L1Cache) Cleanup()

func (*L1Cache) Delete

func (c *L1Cache) Delete(_ string) error

func (*L1Cache) Disable

func (c *L1Cache) Disable()

func (*L1Cache) Enable

func (c *L1Cache) Enable()

func (*L1Cache) Get

func (c *L1Cache) Get(_ string) (interface{}, bool)

func (*L1Cache) GetItemCount

func (c *L1Cache) GetItemCount() int64

func (*L1Cache) GetSize

func (c *L1Cache) GetSize() int64

func (*L1Cache) Set

func (c *L1Cache) Set(_ string, _ interface{}, _ time.Duration) error

func (*L1Cache) Start

func (c *L1Cache) Start(_ context.Context) error

func (*L1Cache) Stop

func (c *L1Cache) Stop(_ context.Context) error

type L2Cache

type L2Cache struct {
	// contains filtered or unexported fields
}

func NewL2Cache

func NewL2Cache(size int64, logger logr.Logger) *L2Cache

func (*L2Cache) Cleanup

func (c *L2Cache) Cleanup(_ context.Context)

func (*L2Cache) Delete

func (c *L2Cache) Delete(_ context.Context, _ string) error

func (*L2Cache) Disable

func (c *L2Cache) Disable()

func (*L2Cache) Enable

func (c *L2Cache) Enable()

func (*L2Cache) Get

func (c *L2Cache) Get(ctx context.Context, key string) (interface{}, error)

func (*L2Cache) GetItemCount

func (c *L2Cache) GetItemCount() int64

func (*L2Cache) GetSize

func (c *L2Cache) GetSize() int64

func (*L2Cache) Set

func (c *L2Cache) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

func (*L2Cache) Start

func (c *L2Cache) Start(_ context.Context) error

func (*L2Cache) Stop

func (c *L2Cache) Stop(_ context.Context) error

type L3Cache

type L3Cache struct {
	// contains filtered or unexported fields
}

func NewL3Cache

func NewL3Cache(logger logr.Logger) *L3Cache

func (*L3Cache) Cleanup

func (c *L3Cache) Cleanup(_ context.Context)

func (*L3Cache) Delete

func (c *L3Cache) Delete(_ context.Context, _ string) error

func (*L3Cache) Disable

func (c *L3Cache) Disable()

func (*L3Cache) Enable

func (c *L3Cache) Enable()

func (*L3Cache) Get

func (c *L3Cache) Get(ctx context.Context, key string) (interface{}, error)

func (*L3Cache) GetItemCount

func (c *L3Cache) GetItemCount() int64

func (*L3Cache) GetSize

func (c *L3Cache) GetSize() int64

func (*L3Cache) Set

func (c *L3Cache) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

func (*L3Cache) Start

func (c *L3Cache) Start(_ context.Context) error

func (*L3Cache) Stop

func (c *L3Cache) Stop(_ context.Context) error

type LoadBalancer

type LoadBalancer struct {
	// contains filtered or unexported fields
}

func NewLoadBalancer

func NewLoadBalancer(logger logr.Logger) *LoadBalancer

type LoadBalancingStrategy

type LoadBalancingStrategy string
const (
	LoadBalancingStrategyRoundRobin LoadBalancingStrategy = "round_robin"

	LoadBalancingStrategyLeastConnections LoadBalancingStrategy = "least_connections"

	LoadBalancingStrategyResourceBased LoadBalancingStrategy = "resource_based"
)

type MetricsAnalyzer

type MetricsAnalyzer struct {
	// contains filtered or unexported fields
}

func NewMetricsAnalyzer

func NewMetricsAnalyzer(logger logr.Logger) *MetricsAnalyzer

func (*MetricsAnalyzer) AnalyzePerformance

func (ma *MetricsAnalyzer) AnalyzePerformance(metrics *SystemMetrics) *PerformanceAnalysis

type MultiLevelCacheManager

type MultiLevelCacheManager struct {
	// contains filtered or unexported fields
}

func NewMultiLevelCacheManager

func NewMultiLevelCacheManager(config *PerformanceConfig, logger logr.Logger) *MultiLevelCacheManager

func (*MultiLevelCacheManager) ApplyCachingProfile

func (cm *MultiLevelCacheManager) ApplyCachingProfile(profile CachingProfile) error

func (*MultiLevelCacheManager) Delete

func (cm *MultiLevelCacheManager) Delete(ctx context.Context, key string) error

func (*MultiLevelCacheManager) Get

func (cm *MultiLevelCacheManager) Get(ctx context.Context, key string) (interface{}, error)

func (*MultiLevelCacheManager) GetCacheMetrics

func (cm *MultiLevelCacheManager) GetCacheMetrics() *CacheMetrics

func (*MultiLevelCacheManager) OptimizeCache

func (cm *MultiLevelCacheManager) OptimizeCache(ctx context.Context, parameters map[string]interface{}) error

func (*MultiLevelCacheManager) Set

func (cm *MultiLevelCacheManager) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

func (*MultiLevelCacheManager) Start

func (*MultiLevelCacheManager) Stop

func (*MultiLevelCacheManager) WarmCache

func (cm *MultiLevelCacheManager) WarmCache(ctx context.Context) error

type NetworkIOMetrics

type NetworkIOMetrics struct {
	BytesIn int64 `json:"bytesIn"`

	BytesOut int64 `json:"bytesOut"`

	PacketsIn int64 `json:"packetsIn"`

	PacketsOut int64 `json:"packetsOut"`
}

type PerformanceAnalysis

type PerformanceAnalysis struct {
	OverallHealth string `json:"overallHealth"` // healthy, degraded, unhealthy

	CPUUtilization float64 `json:"cpuUtilization"`

	MemoryUtilization float64 `json:"memoryUtilization"`

	MaxQueueDepth int `json:"maxQueueDepth"`

	AverageResponseTime time.Duration `json:"averageResponseTime"`

	TotalThroughput float64 `json:"totalThroughput"`

	OverallErrorRate float64 `json:"overallErrorRate"`

	CacheHitRate float64 `json:"cacheHitRate"`

	Bottlenecks []PerformanceBottleneck `json:"bottlenecks"`

	Trends map[string]PerformanceTrend `json:"trends"`
}

type PerformanceBottleneck

type PerformanceBottleneck struct {
	Phase interfaces.ProcessingPhase `json:"phase"`

	Type string `json:"type"` // cpu, memory, io, queue, external

	Severity string `json:"severity"` // low, medium, high, critical

	Description string `json:"description"`

	Impact float64 `json:"impact"` // 0.0 to 1.0
}

type PerformanceConfig

type PerformanceConfig struct {
	MetricsCollectionInterval time.Duration `json:"metricsCollectionInterval"`

	AnalysisInterval time.Duration `json:"analysisInterval"`

	CPUScaleUpThreshold float64 `json:"cpuScaleUpThreshold"`

	CPUScaleDownThreshold float64 `json:"cpuScaleDownThreshold"`

	MemoryScaleUpThreshold float64 `json:"memoryScaleUpThreshold"`

	MemoryScaleDownThreshold float64 `json:"memoryScaleDownThreshold"`

	QueueDepthThreshold int `json:"queueDepthThreshold"`

	ResponseTimeThreshold time.Duration `json:"responseTimeThreshold"`

	MaxConnectionsPerPool int `json:"maxConnectionsPerPool"`

	ConnectionIdleTimeout time.Duration `json:"connectionIdleTimeout"`

	ConnectionMaxLifetime time.Duration `json:"connectionMaxLifetime"`

	L1CacheSize int64 `json:"l1CacheSize"`

	L2CacheSize int64 `json:"l2CacheSize"`

	DefaultCacheTTL time.Duration `json:"defaultCacheTTL"`

	Profiles map[string]PerformanceProfile `json:"profiles"`
}

type PerformanceManager

type PerformanceManager struct {
	// contains filtered or unexported fields
}

func NewPerformanceManager

func NewPerformanceManager(config *PerformanceConfig, logger logr.Logger) *PerformanceManager

func (*PerformanceManager) AutoOptimize

func (pm *PerformanceManager) AutoOptimize(ctx context.Context) error

func (*PerformanceManager) GetPerformanceRecommendations

func (pm *PerformanceManager) GetPerformanceRecommendations(ctx context.Context) (*PerformanceRecommendations, error)

func (*PerformanceManager) OptimizeForProfile

func (pm *PerformanceManager) OptimizeForProfile(ctx context.Context, profileName string, phase interfaces.ProcessingPhase) error

func (*PerformanceManager) Start

func (pm *PerformanceManager) Start(ctx context.Context) error

func (*PerformanceManager) Stop

func (pm *PerformanceManager) Stop(ctx context.Context) error

type PerformanceProfile

type PerformanceProfile struct {
	Name string `json:"name"`

	Description string `json:"description"`

	MaxConcurrentOperations int `json:"maxConcurrentOperations"`

	TimeoutSettings TimeoutProfile `json:"timeoutSettings"`

	CachingStrategy CachingProfile `json:"cachingStrategy"`

	ResourceLimits ResourceProfile `json:"resourceLimits"`

	ScalingPolicy ScalingProfile `json:"scalingPolicy"`
}

type PerformanceRecommendations

type PerformanceRecommendations struct {
	Timestamp time.Time `json:"timestamp"`

	CurrentMetrics *SystemMetrics `json:"currentMetrics"`

	Analysis *PerformanceAnalysis `json:"analysis"`

	Recommendations []Recommendation `json:"recommendations"`
}

type PerformanceTrend

type PerformanceTrend struct {
	Metric string `json:"metric"`

	Direction string `json:"direction"` // improving, degrading, stable

	Rate float64 `json:"rate"` // rate of change

	Confidence float64 `json:"confidence"` // 0.0 to 1.0
}

type Recommendation

type Recommendation struct {
	Type string `json:"type"` // scaling, caching, resource, performance

	Priority string `json:"priority"` // low, medium, high, critical

	Description string `json:"description"`

	Action string `json:"action"` // scale_up, scale_down, optimize_cache, etc.

	Parameters json.RawMessage `json:"parameters"`

	Confidence float64 `json:"confidence"` // 0.0 to 1.0
}

type ResourceMonitor

type ResourceMonitor struct {
	// contains filtered or unexported fields
}

func NewResourceMonitor

func NewResourceMonitor(logger logr.Logger) *ResourceMonitor

func (*ResourceMonitor) CollectMetrics

func (rm *ResourceMonitor) CollectMetrics(ctx context.Context)

func (*ResourceMonitor) GetCurrentMetrics

func (rm *ResourceMonitor) GetCurrentMetrics() *SystemMetrics

func (*ResourceMonitor) GetMetricsHistory

func (rm *ResourceMonitor) GetMetricsHistory(duration time.Duration) []SystemMetrics

func (*ResourceMonitor) Start

func (rm *ResourceMonitor) Start(ctx context.Context) error

func (*ResourceMonitor) Stop

func (rm *ResourceMonitor) Stop(ctx context.Context) error

type ResourceProfile

type ResourceProfile struct {
	CPURequest string `json:"cpuRequest"`

	CPULimit string `json:"cpuLimit"`

	MemoryRequest string `json:"memoryRequest"`

	MemoryLimit string `json:"memoryLimit"`

	MaxWorkers int `json:"maxWorkers"`
}

type ScalingDecision

type ScalingDecision struct {
	Action string `json:"action"` // scale_up, scale_down, no_action

	Phase interfaces.ProcessingPhase `json:"phase"` // which phase to scale

	CurrentReplicas int `json:"currentReplicas"`

	TargetReplicas int `json:"targetReplicas"`

	Reason string `json:"reason"`

	Confidence float64 `json:"confidence"`

	Timestamp time.Time `json:"timestamp"`
}

type ScalingDecisionEngine

type ScalingDecisionEngine struct {
	// contains filtered or unexported fields
}

func NewScalingDecisionEngine

func NewScalingDecisionEngine(config *PerformanceConfig, logger logr.Logger) *ScalingDecisionEngine

func (*ScalingDecisionEngine) ApplyScalingProfile

func (sde *ScalingDecisionEngine) ApplyScalingProfile(profile ScalingProfile)

func (*ScalingDecisionEngine) EvaluateScaling

func (sde *ScalingDecisionEngine) EvaluateScaling(ctx context.Context, metrics *SystemMetrics) []ScalingDecision

type ScalingPolicy

type ScalingPolicy struct {
	MetricType string `json:"metricType"`

	TargetValue float64 `json:"targetValue"`

	StabilizationWindow time.Duration `json:"stabilizationWindow"`

	ScalingFactor float64 `json:"scalingFactor"`
}

type ScalingProfile

type ScalingProfile struct {
	MinReplicas int `json:"minReplicas"`

	MaxReplicas int `json:"maxReplicas"`

	ScaleUpPolicy ScalingPolicy `json:"scaleUpPolicy"`

	ScaleDownPolicy ScalingPolicy `json:"scaleDownPolicy"`
}

type SystemMetrics

type SystemMetrics struct {
	Timestamp time.Time `json:"timestamp"`

	CPUUtilization float64 `json:"cpuUtilization"`

	MemoryUtilization float64 `json:"memoryUtilization"`

	NetworkIO NetworkIOMetrics `json:"networkIO"`

	DiskIO DiskIOMetrics `json:"diskIO"`

	QueueDepths map[interfaces.ProcessingPhase]int `json:"queueDepths"`

	ResponseTimes map[interfaces.ProcessingPhase]time.Duration `json:"responseTimes"`

	ThroughputRates map[interfaces.ProcessingPhase]float64 `json:"throughputRates"`

	ErrorRates map[interfaces.ProcessingPhase]float64 `json:"errorRates"`

	CacheMetrics *CacheMetrics `json:"cacheMetrics"`

	ConnectionMetrics *ConnectionMetrics `json:"connectionMetrics"`
}

type TimeoutProfile

type TimeoutProfile struct {
	LLMProcessing time.Duration `json:"llmProcessing"`

	ResourcePlanning time.Duration `json:"resourcePlanning"`

	ManifestGeneration time.Duration `json:"manifestGeneration"`

	GitOpsCommit time.Duration `json:"gitOpsCommit"`

	DeploymentVerification time.Duration `json:"deploymentVerification"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL