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