1use risingwave_common::config::{
16 EvictionConfig, ObjectStoreConfig, RwConfig, StorageMemoryConfig, extract_storage_memory_config,
17};
18use risingwave_common::system_param::reader::{SystemParamsRead, SystemParamsReader};
19use risingwave_common::system_param::system_params_for_test;
20
21#[derive(Clone, Debug)]
22pub struct StorageOpts {
23 pub parallel_compact_size_mb: u32,
25 pub sstable_size_mb: u32,
27 pub min_sstable_size_mb: u32,
29 pub block_size_kb: u32,
31 pub bloom_false_positive: f64,
33 pub share_buffers_sync_parallelism: u32,
35 pub share_buffer_compaction_worker_threads_number: u32,
38 pub shared_buffer_capacity_mb: usize,
41 pub shared_buffer_flush_ratio: f32,
44 pub shared_buffer_min_batch_flush_size_mb: usize,
47 pub data_directory: String,
49 pub write_conflict_detection_enabled: bool,
51 pub block_cache_capacity_mb: usize,
53 pub block_cache_shard_num: usize,
55 pub block_cache_eviction_config: EvictionConfig,
57 pub meta_cache_capacity_mb: usize,
59 pub meta_cache_shard_num: usize,
61 pub meta_cache_eviction_config: EvictionConfig,
63 pub prefetch_buffer_capacity_mb: usize,
65
66 pub max_cached_recent_versions_number: usize,
67
68 pub max_prefetch_block_number: usize,
69
70 pub disable_remote_compactor: bool,
71 pub share_buffer_upload_concurrency: usize,
73 pub compactor_memory_limit_mb: usize,
75 pub compact_iter_recreate_timeout_ms: u64,
78 pub sstable_id_remote_fetch_number: u32,
80 pub min_sst_size_for_streaming_upload: u64,
82 pub max_concurrent_compaction_task_number: u64,
83 pub max_version_pinning_duration_sec: u64,
84 pub compactor_iter_max_io_retry_times: usize,
85
86 pub data_file_cache_dir: String,
87 pub data_file_cache_capacity_mb: usize,
88 pub data_file_cache_file_capacity_mb: usize,
89 pub data_file_cache_flushers: usize,
90 pub data_file_cache_reclaimers: usize,
91 pub data_file_cache_recover_mode: foyer::RecoverMode,
92 pub data_file_cache_recover_concurrency: usize,
93 pub data_file_cache_indexer_shards: usize,
94 pub data_file_cache_compression: foyer::Compression,
95 pub data_file_cache_flush_buffer_threshold_mb: usize,
96 pub data_file_cache_fifo_probation_ratio: f64,
97 pub data_file_cache_runtime_config: foyer::RuntimeOptions,
98 pub data_file_cache_throttle: foyer::Throttle,
99
100 pub cache_refill_data_refill_levels: Vec<u32>,
101 pub cache_refill_timeout_ms: u64,
102 pub cache_refill_concurrency: usize,
103 pub cache_refill_recent_filter_layers: usize,
104 pub cache_refill_recent_filter_rotate_interval_ms: usize,
105 pub cache_refill_unit: usize,
106 pub cache_refill_threshold: f64,
107
108 pub meta_file_cache_dir: String,
109 pub meta_file_cache_capacity_mb: usize,
110 pub meta_file_cache_file_capacity_mb: usize,
111 pub meta_file_cache_flushers: usize,
112 pub meta_file_cache_reclaimers: usize,
113 pub meta_file_cache_recover_mode: foyer::RecoverMode,
114 pub meta_file_cache_recover_concurrency: usize,
115 pub meta_file_cache_indexer_shards: usize,
116 pub meta_file_cache_compression: foyer::Compression,
117 pub meta_file_cache_flush_buffer_threshold_mb: usize,
118 pub meta_file_cache_fifo_probation_ratio: f64,
119 pub meta_file_cache_runtime_config: foyer::RuntimeOptions,
120 pub meta_file_cache_throttle: foyer::Throttle,
121
122 pub vector_file_block_size_kb: usize,
123 pub vector_block_cache_capacity_mb: usize,
124 pub vector_block_cache_shard_num: usize,
125 pub vector_block_cache_eviction_config: EvictionConfig,
126 pub vector_meta_cache_capacity_mb: usize,
127 pub vector_meta_cache_shard_num: usize,
128 pub vector_meta_cache_eviction_config: EvictionConfig,
129
130 pub backup_storage_url: String,
132 pub backup_storage_directory: String,
134 pub max_preload_wait_time_mill: u64,
136
137 pub compactor_max_sst_key_count: u64,
138 pub compactor_max_task_multiplier: f32,
139 pub compactor_max_sst_size: u64,
140 pub enable_fast_compaction: bool,
142 pub check_compaction_result: bool,
143 pub max_preload_io_retry_times: usize,
144 pub compactor_fast_max_compact_delete_ratio: u32,
145 pub compactor_fast_max_compact_task_size: u64,
146
147 pub mem_table_spill_threshold: usize,
148
149 pub compactor_concurrent_uploading_sst_count: Option<usize>,
150
151 pub compactor_max_overlap_sst_count: usize,
152
153 pub compactor_max_preload_meta_file_count: usize,
155
156 pub object_store_config: ObjectStoreConfig,
157 pub time_travel_version_cache_capacity: u64,
158
159 pub iceberg_compaction_target_file_size_mb: u32,
160 pub iceberg_compaction_enable_validate: bool,
161 pub iceberg_compaction_max_record_batch_rows: usize,
162 pub iceberg_compaction_write_parquet_max_row_group_rows: usize,
163 pub iceberg_compaction_min_size_per_partition_mb: u32,
164 pub iceberg_compaction_max_file_count_per_partition: u32,
165}
166
167impl Default for StorageOpts {
168 fn default() -> Self {
169 let c = RwConfig::default();
170 let p = system_params_for_test();
171 let s = extract_storage_memory_config(&c);
172 Self::from((&c, &p.into(), &s))
173 }
174}
175
176impl From<(&RwConfig, &SystemParamsReader, &StorageMemoryConfig)> for StorageOpts {
177 fn from((c, p, s): (&RwConfig, &SystemParamsReader, &StorageMemoryConfig)) -> Self {
178 let mut data_file_cache_throttle = c.storage.data_file_cache.throttle.clone();
179 if data_file_cache_throttle.write_throughput.is_none() {
180 data_file_cache_throttle = data_file_cache_throttle.with_write_throughput(
181 c.storage.data_file_cache.insert_rate_limit_mb * 1024 * 1024,
182 );
183 }
184 let mut meta_file_cache_throttle = c.storage.meta_file_cache.throttle.clone();
185 if meta_file_cache_throttle.write_throughput.is_none() {
186 meta_file_cache_throttle = meta_file_cache_throttle.with_write_throughput(
187 c.storage.meta_file_cache.insert_rate_limit_mb * 1024 * 1024,
188 );
189 }
190
191 Self {
192 parallel_compact_size_mb: p.parallel_compact_size_mb(),
193 sstable_size_mb: p.sstable_size_mb(),
194 min_sstable_size_mb: c.storage.min_sstable_size_mb,
195 block_size_kb: p.block_size_kb(),
196 bloom_false_positive: p.bloom_false_positive(),
197 share_buffers_sync_parallelism: c.storage.share_buffers_sync_parallelism,
198 share_buffer_compaction_worker_threads_number: c
199 .storage
200 .share_buffer_compaction_worker_threads_number,
201 shared_buffer_capacity_mb: s.shared_buffer_capacity_mb,
202 shared_buffer_flush_ratio: c.storage.shared_buffer_flush_ratio,
203 shared_buffer_min_batch_flush_size_mb: c.storage.shared_buffer_min_batch_flush_size_mb,
204 data_directory: p.data_directory().to_owned(),
205 write_conflict_detection_enabled: c.storage.write_conflict_detection_enabled,
206 block_cache_capacity_mb: s.block_cache_capacity_mb,
207 block_cache_shard_num: s.block_cache_shard_num,
208 block_cache_eviction_config: s.block_cache_eviction_config.clone(),
209 meta_cache_capacity_mb: s.meta_cache_capacity_mb,
210 meta_cache_shard_num: s.meta_cache_shard_num,
211 meta_cache_eviction_config: s.meta_cache_eviction_config.clone(),
212 prefetch_buffer_capacity_mb: s.prefetch_buffer_capacity_mb,
213 max_cached_recent_versions_number: c.storage.max_cached_recent_versions_number,
214 max_prefetch_block_number: c.storage.max_prefetch_block_number,
215 disable_remote_compactor: c.storage.disable_remote_compactor,
216 share_buffer_upload_concurrency: c.storage.share_buffer_upload_concurrency,
217 compactor_memory_limit_mb: s.compactor_memory_limit_mb,
218 sstable_id_remote_fetch_number: c.storage.sstable_id_remote_fetch_number,
219 min_sst_size_for_streaming_upload: c.storage.min_sst_size_for_streaming_upload,
220 max_concurrent_compaction_task_number: c.storage.max_concurrent_compaction_task_number,
221 max_version_pinning_duration_sec: c.storage.max_version_pinning_duration_sec,
222 data_file_cache_dir: c.storage.data_file_cache.dir.clone(),
223 data_file_cache_capacity_mb: c.storage.data_file_cache.capacity_mb,
224 data_file_cache_file_capacity_mb: c.storage.data_file_cache.file_capacity_mb,
225 data_file_cache_flushers: c.storage.data_file_cache.flushers,
226 data_file_cache_reclaimers: c.storage.data_file_cache.reclaimers,
227 data_file_cache_recover_mode: c.storage.data_file_cache.recover_mode,
228 data_file_cache_recover_concurrency: c.storage.data_file_cache.recover_concurrency,
229 data_file_cache_indexer_shards: c.storage.data_file_cache.indexer_shards,
230 data_file_cache_compression: c.storage.data_file_cache.compression,
231 data_file_cache_flush_buffer_threshold_mb: s.block_file_cache_flush_buffer_threshold_mb,
232 data_file_cache_fifo_probation_ratio: c.storage.data_file_cache.fifo_probation_ratio,
233 data_file_cache_runtime_config: c.storage.data_file_cache.runtime_config.clone(),
234 data_file_cache_throttle,
235 meta_file_cache_dir: c.storage.meta_file_cache.dir.clone(),
236 meta_file_cache_capacity_mb: c.storage.meta_file_cache.capacity_mb,
237 meta_file_cache_file_capacity_mb: c.storage.meta_file_cache.file_capacity_mb,
238 meta_file_cache_flushers: c.storage.meta_file_cache.flushers,
239 meta_file_cache_reclaimers: c.storage.meta_file_cache.reclaimers,
240 meta_file_cache_recover_mode: c.storage.meta_file_cache.recover_mode,
241 meta_file_cache_recover_concurrency: c.storage.meta_file_cache.recover_concurrency,
242 meta_file_cache_indexer_shards: c.storage.meta_file_cache.indexer_shards,
243 meta_file_cache_compression: c.storage.meta_file_cache.compression,
244 meta_file_cache_flush_buffer_threshold_mb: s.meta_file_cache_flush_buffer_threshold_mb,
245 meta_file_cache_fifo_probation_ratio: c.storage.meta_file_cache.fifo_probation_ratio,
246 meta_file_cache_runtime_config: c.storage.meta_file_cache.runtime_config.clone(),
247 meta_file_cache_throttle,
248 cache_refill_data_refill_levels: c.storage.cache_refill.data_refill_levels.clone(),
249 cache_refill_timeout_ms: c.storage.cache_refill.timeout_ms,
250 cache_refill_concurrency: c.storage.cache_refill.concurrency,
251 cache_refill_recent_filter_layers: c.storage.cache_refill.recent_filter_layers,
252 cache_refill_recent_filter_rotate_interval_ms: c
253 .storage
254 .cache_refill
255 .recent_filter_rotate_interval_ms,
256 cache_refill_unit: c.storage.cache_refill.unit,
257 cache_refill_threshold: c.storage.cache_refill.threshold,
258 max_preload_wait_time_mill: c.storage.max_preload_wait_time_mill,
259 compact_iter_recreate_timeout_ms: c.storage.compact_iter_recreate_timeout_ms,
260
261 max_preload_io_retry_times: c.storage.max_preload_io_retry_times,
262 backup_storage_url: p.backup_storage_url().to_owned(),
263 backup_storage_directory: p.backup_storage_directory().to_owned(),
264 compactor_max_sst_key_count: c.storage.compactor_max_sst_key_count,
265 compactor_max_task_multiplier: c.storage.compactor_max_task_multiplier,
266 compactor_max_sst_size: c.storage.compactor_max_sst_size,
267 enable_fast_compaction: c.storage.enable_fast_compaction,
268 check_compaction_result: c.storage.check_compaction_result,
269 mem_table_spill_threshold: c.storage.mem_table_spill_threshold,
270 object_store_config: c.storage.object_store.clone(),
271 compactor_fast_max_compact_delete_ratio: c
272 .storage
273 .compactor_fast_max_compact_delete_ratio,
274 compactor_fast_max_compact_task_size: c.storage.compactor_fast_max_compact_task_size,
275 compactor_iter_max_io_retry_times: c.storage.compactor_iter_max_io_retry_times,
276 compactor_concurrent_uploading_sst_count: c
277 .storage
278 .compactor_concurrent_uploading_sst_count,
279 time_travel_version_cache_capacity: c.storage.time_travel_version_cache_capacity,
280 compactor_max_overlap_sst_count: c.storage.compactor_max_overlap_sst_count,
281 compactor_max_preload_meta_file_count: c.storage.compactor_max_preload_meta_file_count,
282
283 iceberg_compaction_target_file_size_mb: c
284 .storage
285 .iceberg_compaction_target_file_size_mb,
286 iceberg_compaction_enable_validate: c.storage.iceberg_compaction_enable_validate,
287 iceberg_compaction_max_record_batch_rows: c
288 .storage
289 .iceberg_compaction_max_record_batch_rows,
290 iceberg_compaction_write_parquet_max_row_group_rows: c
291 .storage
292 .iceberg_compaction_write_parquet_max_row_group_rows,
293 iceberg_compaction_min_size_per_partition_mb: c
294 .storage
295 .iceberg_compaction_min_size_per_partition_mb,
296 iceberg_compaction_max_file_count_per_partition: c
297 .storage
298 .iceberg_compaction_max_file_count_per_partition,
299 vector_file_block_size_kb: c.storage.vector_file_block_size_kb,
300 vector_block_cache_capacity_mb: s.vector_block_cache_capacity_mb,
301 vector_block_cache_shard_num: s.vector_block_cache_shard_num,
302 vector_block_cache_eviction_config: s.vector_block_cache_eviction_config.clone(),
303 vector_meta_cache_capacity_mb: s.vector_meta_cache_capacity_mb,
304 vector_meta_cache_shard_num: s.vector_meta_cache_shard_num,
305 vector_meta_cache_eviction_config: s.vector_meta_cache_eviction_config.clone(),
306 }
307 }
308}