1use risingwave_common::config::storage::FileCacheRuntimeConfig;
16use risingwave_common::config::streaming::CacheRefillPolicy;
17use risingwave_common::config::{
18 EvictionConfig, ObjectStoreConfig, RwConfig, StorageMemoryConfig, extract_storage_memory_config,
19};
20use risingwave_common::system_param::reader::{SystemParamsRead, SystemParamsReader};
21use risingwave_common::system_param::system_params_for_test;
22
23#[derive(Clone, Debug)]
24pub struct StorageOpts {
25 pub parallel_compact_size_mb: u32,
27 pub sstable_size_mb: u32,
29 pub min_sstable_size_mb: u32,
31 pub block_size_kb: u32,
33 pub bloom_false_positive: f64,
35 pub share_buffers_sync_parallelism: u32,
37 pub share_buffer_compaction_worker_threads_number: u32,
40 pub shared_buffer_capacity_mb: usize,
43 pub shared_buffer_flush_ratio: f32,
46 pub shared_buffer_min_batch_flush_size_mb: usize,
49 pub data_directory: String,
51 pub write_conflict_detection_enabled: bool,
53 pub block_cache_capacity_mb: usize,
55 pub block_cache_shard_num: usize,
57 pub block_cache_eviction_config: EvictionConfig,
59 pub meta_cache_capacity_mb: usize,
61 pub meta_cache_shard_num: usize,
63 pub meta_cache_eviction_config: EvictionConfig,
65 pub prefetch_buffer_capacity_mb: usize,
67
68 pub max_cached_recent_versions_number: usize,
69
70 pub max_prefetch_block_number: usize,
71
72 pub disable_remote_compactor: bool,
73 pub share_buffer_upload_concurrency: usize,
75 pub compactor_memory_limit_mb: usize,
77 pub compact_iter_recreate_timeout_ms: u64,
80 pub sstable_id_remote_fetch_number: u32,
82 pub min_sst_size_for_streaming_upload: u64,
84 pub max_concurrent_compaction_task_number: u64,
85 pub max_version_pinning_duration_sec: u64,
86 pub compactor_iter_max_io_retry_times: usize,
87
88 pub shorten_block_meta_key_threshold: Option<usize>,
90
91 pub data_file_cache_dir: String,
92 pub data_file_cache_capacity_mb: usize,
93 pub data_file_cache_file_capacity_mb: usize,
94 pub data_file_cache_flushers: usize,
95 pub data_file_cache_reclaimers: usize,
96 pub data_file_cache_recover_mode: foyer::RecoverMode,
97 pub data_file_cache_recover_concurrency: usize,
98 pub data_file_cache_indexer_shards: usize,
99 pub data_file_cache_compression: foyer::Compression,
100 pub data_file_cache_flush_buffer_threshold_mb: usize,
101 pub data_file_cache_submit_queue_size_threshold_mb: usize,
102 pub data_file_cache_fifo_probation_ratio: f64,
103 pub data_file_cache_blob_index_size_kb: usize,
104 pub data_file_cache_runtime_config: FileCacheRuntimeConfig,
105 pub data_file_cache_throttle: foyer::Throttle,
106
107 pub cache_refill_data_refill_levels: Vec<u32>,
108 pub cache_refill_timeout_ms: u64,
109 pub cache_refill_meta_refill_concurrency: usize,
110 pub cache_refill_concurrency: usize,
111 pub cache_refill_recent_filter_shards: usize,
112 pub cache_refill_recent_filter_layers: usize,
113 pub cache_refill_recent_filter_rotate_interval_ms: usize,
114 pub cache_refill_unit: usize,
115 pub cache_refill_threshold: f64,
116 pub cache_refill_skip_recent_filter: bool,
117 pub cache_refill_skip_inheritance_filter: bool,
118 pub cache_refill_table_cache_refill_default_policy: CacheRefillPolicy,
119
120 pub meta_file_cache_dir: String,
121 pub meta_file_cache_capacity_mb: usize,
122 pub meta_file_cache_file_capacity_mb: usize,
123 pub meta_file_cache_flushers: usize,
124 pub meta_file_cache_reclaimers: usize,
125 pub meta_file_cache_recover_mode: foyer::RecoverMode,
126 pub meta_file_cache_recover_concurrency: usize,
127 pub meta_file_cache_indexer_shards: usize,
128 pub meta_file_cache_compression: foyer::Compression,
129 pub meta_file_cache_flush_buffer_threshold_mb: usize,
130 pub meta_file_cache_submit_queue_size_threshold_mb: usize,
131 pub meta_file_cache_fifo_probation_ratio: f64,
132 pub meta_file_cache_blob_index_size_kb: usize,
133 pub meta_file_cache_runtime_config: FileCacheRuntimeConfig,
134 pub meta_file_cache_throttle: foyer::Throttle,
135 pub sst_skip_bloom_filter_in_serde: bool,
136
137 pub vector_file_block_size_kb: usize,
138 pub vector_block_cache_capacity_mb: usize,
139 pub vector_block_cache_shard_num: usize,
140 pub vector_block_cache_eviction_config: EvictionConfig,
141 pub vector_meta_cache_capacity_mb: usize,
142 pub vector_meta_cache_shard_num: usize,
143 pub vector_meta_cache_eviction_config: EvictionConfig,
144
145 pub backup_storage_url: String,
147 pub backup_storage_directory: String,
149 pub max_preload_wait_time_mill: u64,
151
152 pub compactor_max_sst_key_count: u64,
153 pub compactor_max_task_multiplier: f32,
154 pub compactor_max_sst_size: u64,
155 pub enable_fast_compaction: bool,
157 pub check_compaction_result: bool,
158 pub max_preload_io_retry_times: usize,
159 pub compactor_fast_max_compact_delete_ratio: u32,
160 pub compactor_fast_max_compact_task_size: u64,
161
162 pub mem_table_spill_threshold: usize,
163
164 pub compactor_concurrent_uploading_sst_count: Option<usize>,
165
166 pub compactor_max_overlap_sst_count: usize,
167
168 pub compactor_max_preload_meta_file_count: usize,
170
171 pub object_store_config: ObjectStoreConfig,
172 pub time_travel_version_cache_capacity: u64,
173 pub table_change_log_cache_capacity: u64,
174
175 pub iceberg_compaction_enable_validate: bool,
176 pub iceberg_compaction_max_record_batch_rows: usize,
177 pub iceberg_compaction_write_parquet_max_row_group_rows: usize,
178 pub iceberg_compaction_min_size_per_partition_mb: u32,
179 pub iceberg_compaction_max_file_count_per_partition: u32,
180 pub iceberg_compaction_target_binpack_group_size_mb: Option<u64>,
181 pub iceberg_compaction_min_group_size_mb: Option<u64>,
182 pub iceberg_compaction_min_group_file_count: Option<usize>,
183
184 pub iceberg_compaction_task_parallelism_ratio: f32,
186 pub iceberg_compaction_enable_heuristic_output_parallelism: bool,
188 pub iceberg_compaction_max_concurrent_closes: usize,
190 pub iceberg_compaction_enable_dynamic_size_estimation: bool,
192 pub iceberg_compaction_size_estimation_smoothing_factor: f64,
194 pub iceberg_compaction_pending_parallelism_budget_multiplier: f32,
196 pub iceberg_compaction_pull_interval_ms: u64,
198 pub iceberg_compaction_enable_prefetch: bool,
200}
201
202impl Default for StorageOpts {
203 fn default() -> Self {
204 let c = RwConfig::default();
205 let p = system_params_for_test();
206 let s = extract_storage_memory_config(&c);
207 Self::from((&c, &p.into(), &s))
208 }
209}
210
211impl From<(&RwConfig, &SystemParamsReader, &StorageMemoryConfig)> for StorageOpts {
212 fn from((c, p, s): (&RwConfig, &SystemParamsReader, &StorageMemoryConfig)) -> Self {
213 let mut data_file_cache_throttle = c.storage.data_file_cache.throttle.clone();
214 if data_file_cache_throttle.write_throughput.is_none() {
215 data_file_cache_throttle = data_file_cache_throttle.with_write_throughput(
216 c.storage.data_file_cache.insert_rate_limit_mb * 1024 * 1024,
217 );
218 }
219 let mut meta_file_cache_throttle = c.storage.meta_file_cache.throttle.clone();
220 if meta_file_cache_throttle.write_throughput.is_none() {
221 meta_file_cache_throttle = meta_file_cache_throttle.with_write_throughput(
222 c.storage.meta_file_cache.insert_rate_limit_mb * 1024 * 1024,
223 );
224 }
225
226 Self {
227 parallel_compact_size_mb: p.parallel_compact_size_mb(),
228 sstable_size_mb: p.sstable_size_mb(),
229 min_sstable_size_mb: c.storage.min_sstable_size_mb,
230 block_size_kb: p.block_size_kb(),
231 bloom_false_positive: p.bloom_false_positive(),
232 share_buffers_sync_parallelism: c.storage.share_buffers_sync_parallelism,
233 share_buffer_compaction_worker_threads_number: c
234 .storage
235 .share_buffer_compaction_worker_threads_number,
236 shared_buffer_capacity_mb: s.shared_buffer_capacity_mb,
237 shared_buffer_flush_ratio: c.storage.shared_buffer_flush_ratio,
238 shared_buffer_min_batch_flush_size_mb: c.storage.shared_buffer_min_batch_flush_size_mb,
239 data_directory: p.data_directory().to_owned(),
240 write_conflict_detection_enabled: c.storage.write_conflict_detection_enabled,
241 block_cache_capacity_mb: s.block_cache_capacity_mb,
242 block_cache_shard_num: s.block_cache_shard_num,
243 block_cache_eviction_config: s.block_cache_eviction_config.clone(),
244 meta_cache_capacity_mb: s.meta_cache_capacity_mb,
245 meta_cache_shard_num: s.meta_cache_shard_num,
246 meta_cache_eviction_config: s.meta_cache_eviction_config.clone(),
247 prefetch_buffer_capacity_mb: s.prefetch_buffer_capacity_mb,
248 max_cached_recent_versions_number: c.storage.max_cached_recent_versions_number,
249 max_prefetch_block_number: c.storage.max_prefetch_block_number,
250 disable_remote_compactor: c.storage.disable_remote_compactor,
251 share_buffer_upload_concurrency: c.storage.share_buffer_upload_concurrency,
252 compactor_memory_limit_mb: s.compactor_memory_limit_mb,
253 sstable_id_remote_fetch_number: c.storage.sstable_id_remote_fetch_number,
254 min_sst_size_for_streaming_upload: c.storage.min_sst_size_for_streaming_upload,
255 max_concurrent_compaction_task_number: c.storage.max_concurrent_compaction_task_number,
256 max_version_pinning_duration_sec: c.storage.max_version_pinning_duration_sec,
257 data_file_cache_dir: c.storage.data_file_cache.dir.clone(),
258 data_file_cache_capacity_mb: c.storage.data_file_cache.capacity_mb,
259 data_file_cache_file_capacity_mb: c.storage.data_file_cache.file_capacity_mb,
260 data_file_cache_flushers: c.storage.data_file_cache.flushers,
261 data_file_cache_reclaimers: c.storage.data_file_cache.reclaimers,
262 data_file_cache_recover_mode: c.storage.data_file_cache.recover_mode,
263 data_file_cache_recover_concurrency: c.storage.data_file_cache.recover_concurrency,
264 data_file_cache_indexer_shards: c.storage.data_file_cache.indexer_shards,
265 data_file_cache_compression: c.storage.data_file_cache.compression,
266 data_file_cache_flush_buffer_threshold_mb: s.block_file_cache_flush_buffer_threshold_mb,
267 data_file_cache_submit_queue_size_threshold_mb: c
268 .storage
269 .data_file_cache
270 .submit_queue_size_threshold_mb,
271 data_file_cache_fifo_probation_ratio: c.storage.data_file_cache.fifo_probation_ratio,
272 data_file_cache_blob_index_size_kb: c.storage.data_file_cache.blob_index_size_kb,
273 data_file_cache_runtime_config: c.storage.data_file_cache.runtime_config.clone(),
274 data_file_cache_throttle,
275 meta_file_cache_dir: c.storage.meta_file_cache.dir.clone(),
276 meta_file_cache_capacity_mb: c.storage.meta_file_cache.capacity_mb,
277 meta_file_cache_file_capacity_mb: c.storage.meta_file_cache.file_capacity_mb,
278 meta_file_cache_flushers: c.storage.meta_file_cache.flushers,
279 meta_file_cache_reclaimers: c.storage.meta_file_cache.reclaimers,
280 meta_file_cache_recover_mode: c.storage.meta_file_cache.recover_mode,
281 meta_file_cache_recover_concurrency: c.storage.meta_file_cache.recover_concurrency,
282 meta_file_cache_indexer_shards: c.storage.meta_file_cache.indexer_shards,
283 meta_file_cache_compression: c.storage.meta_file_cache.compression,
284 meta_file_cache_flush_buffer_threshold_mb: s.meta_file_cache_flush_buffer_threshold_mb,
285 meta_file_cache_submit_queue_size_threshold_mb: c
286 .storage
287 .meta_file_cache
288 .submit_queue_size_threshold_mb,
289 meta_file_cache_fifo_probation_ratio: c.storage.meta_file_cache.fifo_probation_ratio,
290 meta_file_cache_blob_index_size_kb: c.storage.meta_file_cache.blob_index_size_kb,
291 meta_file_cache_runtime_config: c.storage.meta_file_cache.runtime_config.clone(),
292 meta_file_cache_throttle,
293 sst_skip_bloom_filter_in_serde: c.storage.sst_skip_bloom_filter_in_serde,
294 cache_refill_data_refill_levels: c.storage.cache_refill.data_refill_levels.clone(),
295 cache_refill_timeout_ms: c.storage.cache_refill.timeout_ms,
296 cache_refill_meta_refill_concurrency: c.storage.cache_refill.meta_refill_concurrency,
297 cache_refill_concurrency: c.storage.cache_refill.concurrency,
298 cache_refill_recent_filter_shards: c.storage.cache_refill.recent_filter_shards,
299 cache_refill_recent_filter_layers: c.storage.cache_refill.recent_filter_layers,
300 cache_refill_recent_filter_rotate_interval_ms: c
301 .storage
302 .cache_refill
303 .recent_filter_rotate_interval_ms,
304 cache_refill_unit: c.storage.cache_refill.unit,
305 cache_refill_threshold: c.storage.cache_refill.threshold,
306 cache_refill_skip_recent_filter: c.storage.cache_refill.skip_recent_filter,
307 cache_refill_skip_inheritance_filter: c.storage.cache_refill.skip_inheritance_filter,
308 cache_refill_table_cache_refill_default_policy: c
309 .streaming
310 .developer
311 .cache_refill_policy,
312 max_preload_wait_time_mill: c.storage.max_preload_wait_time_mill,
313 compact_iter_recreate_timeout_ms: c.storage.compact_iter_recreate_timeout_ms,
314
315 max_preload_io_retry_times: c.storage.max_preload_io_retry_times,
316 backup_storage_url: p.backup_storage_url().to_owned(),
317 backup_storage_directory: p.backup_storage_directory().to_owned(),
318 compactor_max_sst_key_count: c.storage.compactor_max_sst_key_count,
319 compactor_max_task_multiplier: c.storage.compactor_max_task_multiplier,
320 compactor_max_sst_size: c.storage.compactor_max_sst_size,
321 enable_fast_compaction: c.storage.enable_fast_compaction,
322 check_compaction_result: c.storage.check_compaction_result,
323 mem_table_spill_threshold: c.storage.mem_table_spill_threshold,
324 object_store_config: c.storage.object_store.clone(),
325 compactor_fast_max_compact_delete_ratio: c
326 .storage
327 .compactor_fast_max_compact_delete_ratio,
328 compactor_fast_max_compact_task_size: c.storage.compactor_fast_max_compact_task_size,
329 compactor_iter_max_io_retry_times: c.storage.compactor_iter_max_io_retry_times,
330 shorten_block_meta_key_threshold: c.storage.shorten_block_meta_key_threshold,
331 compactor_concurrent_uploading_sst_count: c
332 .storage
333 .compactor_concurrent_uploading_sst_count,
334 time_travel_version_cache_capacity: c.storage.time_travel_version_cache_capacity,
335 table_change_log_cache_capacity: c.storage.table_change_log_cache_capacity,
336 compactor_max_overlap_sst_count: c.storage.compactor_max_overlap_sst_count,
337 compactor_max_preload_meta_file_count: c.storage.compactor_max_preload_meta_file_count,
338
339 iceberg_compaction_enable_validate: c.storage.iceberg_compaction_enable_validate,
340 iceberg_compaction_max_record_batch_rows: c
341 .storage
342 .iceberg_compaction_max_record_batch_rows,
343 #[expect(deprecated)]
344 iceberg_compaction_write_parquet_max_row_group_rows: c
345 .storage
346 .iceberg_compaction_write_parquet_max_row_group_rows,
347 iceberg_compaction_min_size_per_partition_mb: c
348 .storage
349 .iceberg_compaction_min_size_per_partition_mb,
350 iceberg_compaction_max_file_count_per_partition: c
351 .storage
352 .iceberg_compaction_max_file_count_per_partition,
353 iceberg_compaction_task_parallelism_ratio: c
354 .storage
355 .iceberg_compaction_task_parallelism_ratio,
356 iceberg_compaction_enable_heuristic_output_parallelism: c
357 .storage
358 .iceberg_compaction_enable_heuristic_output_parallelism,
359 iceberg_compaction_max_concurrent_closes: c
360 .storage
361 .iceberg_compaction_max_concurrent_closes,
362 iceberg_compaction_enable_dynamic_size_estimation: c
363 .storage
364 .iceberg_compaction_enable_dynamic_size_estimation,
365 iceberg_compaction_size_estimation_smoothing_factor: c
366 .storage
367 .iceberg_compaction_size_estimation_smoothing_factor,
368 iceberg_compaction_pending_parallelism_budget_multiplier: c
369 .storage
370 .iceberg_compaction_pending_parallelism_budget_multiplier,
371 iceberg_compaction_pull_interval_ms: c.storage.iceberg_compaction_pull_interval_ms,
372 iceberg_compaction_enable_prefetch: c.storage.iceberg_compaction_enable_prefetch,
373 iceberg_compaction_target_binpack_group_size_mb: c
374 .storage
375 .iceberg_compaction_target_binpack_group_size_mb,
376 iceberg_compaction_min_group_size_mb: c.storage.iceberg_compaction_min_group_size_mb,
377 iceberg_compaction_min_group_file_count: c
378 .storage
379 .iceberg_compaction_min_group_file_count,
380 vector_file_block_size_kb: c.storage.vector_file_block_size_kb,
381 vector_block_cache_capacity_mb: s.vector_block_cache_capacity_mb,
382 vector_block_cache_shard_num: s.vector_block_cache_shard_num,
383 vector_block_cache_eviction_config: s.vector_block_cache_eviction_config.clone(),
384 vector_meta_cache_capacity_mb: s.vector_meta_cache_capacity_mb,
385 vector_meta_cache_shard_num: s.vector_meta_cache_shard_num,
386 vector_meta_cache_eviction_config: s.vector_meta_cache_eviction_config.clone(),
387 }
388 }
389}
390
391#[cfg(test)]
392mod tests {
393 use super::*;
394
395 #[test]
396 fn test_file_cache_submit_queue_size_threshold() {
397 let mut config = RwConfig::default();
398 config
399 .storage
400 .data_file_cache
401 .submit_queue_size_threshold_mb = 256;
402 config
403 .storage
404 .meta_file_cache
405 .submit_queue_size_threshold_mb = 32;
406 let system_params = system_params_for_test();
407 let storage_memory_config = extract_storage_memory_config(&config);
408
409 let opts = StorageOpts::from((&config, &system_params.into(), &storage_memory_config));
410
411 assert_eq!(opts.data_file_cache_submit_queue_size_threshold_mb, 256);
412 assert_eq!(opts.meta_file_cache_submit_queue_size_threshold_mb, 32);
413 }
414}