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: std::thread::available_parallelism()
50 .map(|n| n.get())
51 .unwrap_or(1)
52 .max(1),
53 enable_event_filtering: true,
54 enable_compression: true,
55 compression_threshold: 1024, enable_adaptive_compression: true,
57 estimated_bandwidth: 100 * 1024 * 1024, }
59 }
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct EnhancedMLConfig {
65 pub enable_enhanced_ml: bool,
67 pub learning_rate: f64,
69 pub training_epochs: usize,
71 pub ml_batch_size: usize,
73 pub hidden_layer_size: usize,
75 pub enable_feature_engineering: bool,
77 pub enable_polynomial_features: bool,
79 pub polynomial_degree: usize,
81 pub enable_interaction_features: bool,
83 pub enable_temporal_features: bool,
85 pub enable_statistical_features: bool,
87 pub enable_model_selection: bool,
89 pub cv_folds: usize,
91 pub enable_feature_scaling: bool,
93 pub performance_window: usize,
95}
96
97impl Default for EnhancedMLConfig {
98 fn default() -> Self {
99 Self {
100 enable_enhanced_ml: true,
101 learning_rate: 0.01,
102 training_epochs: 100,
103 ml_batch_size: 32,
104 hidden_layer_size: 64,
105 enable_feature_engineering: true,
106 enable_polynomial_features: true,
107 polynomial_degree: 2,
108 enable_interaction_features: true,
109 enable_temporal_features: true,
110 enable_statistical_features: true,
111 enable_model_selection: true,
112 cv_folds: 5,
113 enable_feature_scaling: true,
114 performance_window: 1000,
115 }
116 }
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121pub struct BatchConfig {
122 pub initial_batch_size: usize,
124 pub min_batch_size: usize,
126 pub max_batch_size: usize,
128 pub adjustment_factor: f64,
130 pub target_latency_ms: u64,
132 pub latency_tolerance_ms: u64,
134}
135
136impl Default for BatchConfig {
137 fn default() -> Self {
138 Self {
139 initial_batch_size: 100,
140 min_batch_size: 10,
141 max_batch_size: 1000,
142 adjustment_factor: 1.2,
143 target_latency_ms: 10,
144 latency_tolerance_ms: 2,
145 }
146 }
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
151pub struct MemoryPoolConfig {
152 pub initial_size: usize,
154 pub max_size: usize,
156 pub growth_factor: f64,
158 pub shrink_threshold: f64,
160 pub enable_compaction: bool,
162 pub compaction_interval: u64,
164}
165
166impl Default for MemoryPoolConfig {
167 fn default() -> Self {
168 Self {
169 initial_size: 1024 * 1024, max_size: 100 * 1024 * 1024, growth_factor: 1.5,
172 shrink_threshold: 0.7,
173 enable_compaction: true,
174 compaction_interval: 60,
175 }
176 }
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
181pub struct ParallelConfig {
182 pub worker_threads: usize,
184 pub queue_capacity: usize,
186 pub enable_work_stealing: bool,
188 pub load_balancing: LoadBalancingStrategy,
190 pub enable_thread_pinning: bool,
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196pub enum LoadBalancingStrategy {
197 RoundRobin,
198 LeastLoaded,
199 Random,
200 Weighted(Vec<f64>),
201}
202
203impl Default for ParallelConfig {
204 fn default() -> Self {
205 Self {
206 worker_threads: std::thread::available_parallelism()
207 .map(|n| n.get())
208 .unwrap_or(1)
209 .max(1),
210 queue_capacity: 1000,
211 enable_work_stealing: true,
212 load_balancing: LoadBalancingStrategy::LeastLoaded,
213 enable_thread_pinning: false,
214 }
215 }
216}
217
218#[derive(Debug, Clone, Serialize, Deserialize)]
220pub struct CompressionConfig {
221 pub enable_compression: bool,
223 pub algorithm: CompressionAlgorithm,
225 pub level: u32,
227 pub threshold: usize,
229 pub enable_adaptive: bool,
231 pub bandwidth_threshold: u64,
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize)]
237pub enum CompressionAlgorithm {
238 Gzip,
239 Zstd,
240 Lz4,
241 Snappy,
242 Brotli,
243}
244
245impl Default for CompressionConfig {
246 fn default() -> Self {
247 Self {
248 enable_compression: true,
249 algorithm: CompressionAlgorithm::Zstd,
250 level: 3,
251 threshold: 1024, enable_adaptive: true,
253 bandwidth_threshold: 10 * 1024 * 1024, }
255 }
256}