oxirs_stream/performance_optimizer/
config.rs1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct PerformanceConfig {
11 pub enable_adaptive_batching: bool,
13 pub max_batch_size: usize,
15 pub target_latency_ms: u64,
17 pub enable_memory_pooling: bool,
19 pub memory_pool_size: usize,
21 pub enable_zero_copy: bool,
23 pub enable_parallel_processing: bool,
25 pub parallel_workers: usize,
27 pub enable_event_filtering: bool,
29 pub enable_compression: bool,
31 pub compression_threshold: usize,
33 pub enable_adaptive_compression: bool,
35 pub estimated_bandwidth: u64,
37}
38
39impl Default for PerformanceConfig {
40 fn default() -> Self {
41 Self {
42 enable_adaptive_batching: true,
43 max_batch_size: 1000,
44 target_latency_ms: 10,
45 enable_memory_pooling: true,
46 memory_pool_size: 1024 * 1024 * 10, enable_zero_copy: true,
48 enable_parallel_processing: true,
49 parallel_workers: num_cpus::get().max(1),
50 enable_event_filtering: true,
51 enable_compression: true,
52 compression_threshold: 1024, enable_adaptive_compression: true,
54 estimated_bandwidth: 100 * 1024 * 1024, }
56 }
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct EnhancedMLConfig {
62 pub enable_enhanced_ml: bool,
64 pub learning_rate: f64,
66 pub training_epochs: usize,
68 pub ml_batch_size: usize,
70 pub hidden_layer_size: usize,
72 pub enable_feature_engineering: bool,
74 pub enable_polynomial_features: bool,
76 pub polynomial_degree: usize,
78 pub enable_interaction_features: bool,
80 pub enable_temporal_features: bool,
82 pub enable_statistical_features: bool,
84 pub enable_model_selection: bool,
86 pub cv_folds: usize,
88 pub enable_feature_scaling: bool,
90 pub performance_window: usize,
92}
93
94impl Default for EnhancedMLConfig {
95 fn default() -> Self {
96 Self {
97 enable_enhanced_ml: true,
98 learning_rate: 0.01,
99 training_epochs: 100,
100 ml_batch_size: 32,
101 hidden_layer_size: 64,
102 enable_feature_engineering: true,
103 enable_polynomial_features: true,
104 polynomial_degree: 2,
105 enable_interaction_features: true,
106 enable_temporal_features: true,
107 enable_statistical_features: true,
108 enable_model_selection: true,
109 cv_folds: 5,
110 enable_feature_scaling: true,
111 performance_window: 1000,
112 }
113 }
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118pub struct BatchConfig {
119 pub initial_batch_size: usize,
121 pub min_batch_size: usize,
123 pub max_batch_size: usize,
125 pub adjustment_factor: f64,
127 pub target_latency_ms: u64,
129 pub latency_tolerance_ms: u64,
131}
132
133impl Default for BatchConfig {
134 fn default() -> Self {
135 Self {
136 initial_batch_size: 100,
137 min_batch_size: 10,
138 max_batch_size: 1000,
139 adjustment_factor: 1.2,
140 target_latency_ms: 10,
141 latency_tolerance_ms: 2,
142 }
143 }
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct MemoryPoolConfig {
149 pub initial_size: usize,
151 pub max_size: usize,
153 pub growth_factor: f64,
155 pub shrink_threshold: f64,
157 pub enable_compaction: bool,
159 pub compaction_interval: u64,
161}
162
163impl Default for MemoryPoolConfig {
164 fn default() -> Self {
165 Self {
166 initial_size: 1024 * 1024, max_size: 100 * 1024 * 1024, growth_factor: 1.5,
169 shrink_threshold: 0.7,
170 enable_compaction: true,
171 compaction_interval: 60,
172 }
173 }
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize)]
178pub struct ParallelConfig {
179 pub worker_threads: usize,
181 pub queue_capacity: usize,
183 pub enable_work_stealing: bool,
185 pub load_balancing: LoadBalancingStrategy,
187 pub enable_thread_pinning: bool,
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize)]
193pub enum LoadBalancingStrategy {
194 RoundRobin,
195 LeastLoaded,
196 Random,
197 Weighted(Vec<f64>),
198}
199
200impl Default for ParallelConfig {
201 fn default() -> Self {
202 Self {
203 worker_threads: num_cpus::get().max(1),
204 queue_capacity: 1000,
205 enable_work_stealing: true,
206 load_balancing: LoadBalancingStrategy::LeastLoaded,
207 enable_thread_pinning: false,
208 }
209 }
210}
211
212#[derive(Debug, Clone, Serialize, Deserialize)]
214pub struct CompressionConfig {
215 pub enable_compression: bool,
217 pub algorithm: CompressionAlgorithm,
219 pub level: u32,
221 pub threshold: usize,
223 pub enable_adaptive: bool,
225 pub bandwidth_threshold: u64,
227}
228
229#[derive(Debug, Clone, Serialize, Deserialize)]
231pub enum CompressionAlgorithm {
232 Gzip,
233 Zstd,
234 Lz4,
235 Snappy,
236 Brotli,
237}
238
239impl Default for CompressionConfig {
240 fn default() -> Self {
241 Self {
242 enable_compression: true,
243 algorithm: CompressionAlgorithm::Zstd,
244 level: 3,
245 threshold: 1024, enable_adaptive: true,
247 bandwidth_threshold: 10 * 1024 * 1024, }
249 }
250}