optimization

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextOptimizer

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

ContextOptimizer optimizes context variable usage in templates to reduce memory footprint and improve performance

func NewContextOptimizer

func NewContextOptimizer(options *ContextOptimizerOptions) *ContextOptimizer

NewContextOptimizer creates a new context optimizer

func (*ContextOptimizer) ClearSharedVariables

func (o *ContextOptimizer) ClearSharedVariables()

ClearSharedVariables clears the shared variables

func (*ContextOptimizer) GetEnableCompression

func (o *ContextOptimizer) GetEnableCompression() bool

GetEnableCompression returns whether variable compression is enabled

func (*ContextOptimizer) GetEnableDeduplication

func (o *ContextOptimizer) GetEnableDeduplication() bool

GetEnableDeduplication returns whether variable deduplication is enabled

func (*ContextOptimizer) GetEnableLazyLoading

func (o *ContextOptimizer) GetEnableLazyLoading() bool

GetEnableLazyLoading returns whether lazy loading of variables is enabled

func (*ContextOptimizer) GetHighUsageVariables

func (o *ContextOptimizer) GetHighUsageVariables(threshold int) map[string]int

GetHighUsageVariables returns variables with high usage

func (*ContextOptimizer) GetLowUsageVariables

func (o *ContextOptimizer) GetLowUsageVariables(threshold int) map[string]int

GetLowUsageVariables returns variables with low usage

func (*ContextOptimizer) GetSharedVariables

func (o *ContextOptimizer) GetSharedVariables() map[string]string

GetSharedVariables returns the shared variables

func (*ContextOptimizer) GetVariableUsageCount

func (o *ContextOptimizer) GetVariableUsageCount() map[string]int

GetVariableUsageCount returns the variable usage count

func (*ContextOptimizer) OptimizeTemplate

func (o *ContextOptimizer) OptimizeTemplate(ctx context.Context, template *format.Template) (*format.Template, error)

OptimizeTemplate optimizes context variable usage in a template

func (*ContextOptimizer) OptimizeTemplates

func (o *ContextOptimizer) OptimizeTemplates(ctx context.Context, templates []*format.Template) ([]*format.Template, error)

OptimizeTemplates optimizes context variable usage in multiple templates

func (*ContextOptimizer) SetEnableCompression

func (o *ContextOptimizer) SetEnableCompression(enable bool)

SetEnableCompression sets whether variable compression is enabled

func (*ContextOptimizer) SetEnableDeduplication

func (o *ContextOptimizer) SetEnableDeduplication(enable bool)

SetEnableDeduplication sets whether variable deduplication is enabled

func (*ContextOptimizer) SetEnableLazyLoading

func (o *ContextOptimizer) SetEnableLazyLoading(enable bool)

SetEnableLazyLoading sets whether lazy loading of variables is enabled

type ContextOptimizerOptions

type ContextOptimizerOptions struct {
	// EnableDeduplication enables variable deduplication
	EnableDeduplication bool
	// EnableLazyLoading enables lazy loading of variables
	EnableLazyLoading bool
	// EnableCompression enables variable compression
	EnableCompression bool
}

ContextOptimizerOptions contains options for the context optimizer

func DefaultContextOptimizerOptions

func DefaultContextOptimizerOptions() *ContextOptimizerOptions

DefaultContextOptimizerOptions returns default options for the context optimizer

type InheritanceOptimizer

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

InheritanceOptimizer optimizes template inheritance by flattening inheritance chains and reducing the depth of template inheritance hierarchies

func NewInheritanceOptimizer

func NewInheritanceOptimizer(options *InheritanceOptimizerOptions) *InheritanceOptimizer

NewInheritanceOptimizer creates a new inheritance optimizer

func (*InheritanceOptimizer) ClearCache

func (o *InheritanceOptimizer) ClearCache()

ClearCache clears the template cache

func (*InheritanceOptimizer) GetCacheOptimizedTemplates

func (o *InheritanceOptimizer) GetCacheOptimizedTemplates() bool

GetCacheOptimizedTemplates returns whether optimized templates are cached

func (*InheritanceOptimizer) GetCacheSize

func (o *InheritanceOptimizer) GetCacheSize() int

GetCacheSize returns the size of the template cache

func (*InheritanceOptimizer) GetFlattenInheritance

func (o *InheritanceOptimizer) GetFlattenInheritance() bool

GetFlattenInheritance returns whether inheritance is flattened

func (*InheritanceOptimizer) GetMaxInheritanceDepth

func (o *InheritanceOptimizer) GetMaxInheritanceDepth() int

GetMaxInheritanceDepth returns the maximum allowed inheritance depth

func (*InheritanceOptimizer) OptimizeTemplate

func (o *InheritanceOptimizer) OptimizeTemplate(ctx context.Context, template *format.Template) (*format.Template, error)

OptimizeTemplate optimizes a template by flattening inheritance chains and reducing the depth of template inheritance hierarchies

func (*InheritanceOptimizer) OptimizeTemplates

func (o *InheritanceOptimizer) OptimizeTemplates(ctx context.Context, templates []*format.Template) ([]*format.Template, error)

OptimizeTemplates optimizes multiple templates

func (*InheritanceOptimizer) SetCacheOptimizedTemplates

func (o *InheritanceOptimizer) SetCacheOptimizedTemplates(cache bool)

SetCacheOptimizedTemplates sets whether optimized templates should be cached

func (*InheritanceOptimizer) SetFlattenInheritance

func (o *InheritanceOptimizer) SetFlattenInheritance(flatten bool)

SetFlattenInheritance sets whether inheritance should be flattened

func (*InheritanceOptimizer) SetMaxInheritanceDepth

func (o *InheritanceOptimizer) SetMaxInheritanceDepth(depth int)

SetMaxInheritanceDepth sets the maximum allowed inheritance depth

type InheritanceOptimizerOptions

type InheritanceOptimizerOptions struct {
	// MaxInheritanceDepth is the maximum allowed inheritance depth
	MaxInheritanceDepth int
	// FlattenInheritance indicates if inheritance should be flattened
	FlattenInheritance bool
	// CacheOptimizedTemplates indicates if optimized templates should be cached
	CacheOptimizedTemplates bool
}

InheritanceOptimizerOptions contains options for the inheritance optimizer

func DefaultInheritanceOptimizerOptions

func DefaultInheritanceOptimizerOptions() *InheritanceOptimizerOptions

DefaultInheritanceOptimizerOptions returns default options for the inheritance optimizer

type MemoryConfig added in v0.8.0

type MemoryConfig struct {
	MaxMemoryMB   int64
	GCInterval    time.Duration
	PoolSize      int
	CacheTimeout  time.Duration
	EnablePooling bool
}

MemoryConfig configuration for memory optimizer

type MemoryOptimizer

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

MemoryOptimizer handles memory optimization for template processing

func NewMemoryOptimizer

func NewMemoryOptimizer(config MemoryConfig) *MemoryOptimizer

NewMemoryOptimizer creates a new memory optimizer

func (*MemoryOptimizer) ClearPools added in v0.8.0

func (mo *MemoryOptimizer) ClearPools()

ClearPools clears all object pools

func (*MemoryOptimizer) Close added in v0.8.0

func (mo *MemoryOptimizer) Close() error

Close shuts down the memory optimizer

func (*MemoryOptimizer) GetFromPool added in v0.8.0

func (mo *MemoryOptimizer) GetFromPool(poolName string) interface{}

GetFromPool retrieves an object from the specified pool

func (*MemoryOptimizer) GetMemoryUsage added in v0.8.0

func (mo *MemoryOptimizer) GetMemoryUsage() int64

GetMemoryUsage returns current memory usage in MB

func (*MemoryOptimizer) GetStats

func (mo *MemoryOptimizer) GetStats() OptimizationStats

GetStats returns current optimization statistics

func (*MemoryOptimizer) OptimizeMemory added in v0.8.0

func (mo *MemoryOptimizer) OptimizeMemory(ctx context.Context) error

OptimizeMemory performs memory optimization

func (*MemoryOptimizer) PutToPool added in v0.8.0

func (mo *MemoryOptimizer) PutToPool(poolName string, obj interface{})

PutToPool returns an object to the specified pool

func (*MemoryOptimizer) ResizePool added in v0.8.0

func (mo *MemoryOptimizer) ResizePool(poolName string, newSize int) error

ResizePool resizes a specific pool

func (*MemoryOptimizer) SetMaxMemory added in v0.8.0

func (mo *MemoryOptimizer) SetMaxMemory(maxMemoryMB int64)

SetMaxMemory updates the maximum memory threshold

type OptimizationStats added in v0.8.0

type OptimizationStats struct {
	GCRuns           int64
	MemoryFreed      int64
	PoolHits         int64
	PoolMisses       int64
	OptimizationTime time.Duration
}

OptimizationStats tracks memory optimization statistics

type TemplateCache added in v0.8.0

type TemplateCache struct {
	Data       interface{}
	Size       int64
	LastAccess time.Time
	RefCount   int32
}

TemplateCache represents cached template data

Jump to

Keyboard shortcuts

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