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 shorten_block_meta_key_threshold: Option<usize>,
88
89 pub data_file_cache_dir: String,
90 pub data_file_cache_capacity_mb: usize,
91 pub data_file_cache_file_capacity_mb: usize,
92 pub data_file_cache_flushers: usize,
93 pub data_file_cache_reclaimers: usize,
94 pub data_file_cache_recover_mode: foyer::RecoverMode,
95 pub data_file_cache_recover_concurrency: usize,
96 pub data_file_cache_indexer_shards: usize,
97 pub data_file_cache_compression: foyer::Compression,
98 pub data_file_cache_flush_buffer_threshold_mb: usize,
99 pub data_file_cache_fifo_probation_ratio: f64,
100 pub data_file_cache_blob_index_size_kb: usize,
101 pub data_file_cache_runtime_config: foyer::RuntimeOptions,
102 pub data_file_cache_throttle: foyer::Throttle,
103
104 pub cache_refill_data_refill_levels: Vec<u32>,
105 pub cache_refill_timeout_ms: u64,
106 pub cache_refill_meta_refill_concurrency: usize,
107 pub cache_refill_concurrency: usize,
108 pub cache_refill_recent_filter_shards: usize,
109 pub cache_refill_recent_filter_layers: usize,
110 pub cache_refill_recent_filter_rotate_interval_ms: usize,
111 pub cache_refill_unit: usize,
112 pub cache_refill_threshold: f64,
113 pub cache_refill_skip_recent_filter: bool,
114
115 pub meta_file_cache_dir: String,
116 pub meta_file_cache_capacity_mb: usize,
117 pub meta_file_cache_file_capacity_mb: usize,
118 pub meta_file_cache_flushers: usize,
119 pub meta_file_cache_reclaimers: usize,
120 pub meta_file_cache_recover_mode: foyer::RecoverMode,
121 pub meta_file_cache_recover_concurrency: usize,
122 pub meta_file_cache_indexer_shards: usize,
123 pub meta_file_cache_compression: foyer::Compression,
124 pub meta_file_cache_flush_buffer_threshold_mb: usize,
125 pub meta_file_cache_fifo_probation_ratio: f64,
126 pub meta_file_cache_blob_index_size_kb: usize,
127 pub meta_file_cache_runtime_config: foyer::RuntimeOptions,
128 pub meta_file_cache_throttle: foyer::Throttle,
129 pub sst_skip_bloom_filter_in_serde: bool,
130
131 pub vector_file_block_size_kb: usize,
132 pub vector_block_cache_capacity_mb: usize,
133 pub vector_block_cache_shard_num: usize,
134 pub vector_block_cache_eviction_config: EvictionConfig,
135 pub vector_meta_cache_capacity_mb: usize,
136 pub vector_meta_cache_shard_num: usize,
137 pub vector_meta_cache_eviction_config: EvictionConfig,
138
139 pub backup_storage_url: String,
141 pub backup_storage_directory: String,
143 pub max_preload_wait_time_mill: u64,
145
146 pub compactor_max_sst_key_count: u64,
147 pub compactor_max_task_multiplier: f32,
148 pub compactor_max_sst_size: u64,
149 pub enable_fast_compaction: bool,
151 pub check_compaction_result: bool,
152 pub max_preload_io_retry_times: usize,
153 pub compactor_fast_max_compact_delete_ratio: u32,
154 pub compactor_fast_max_compact_task_size: u64,
155
156 pub mem_table_spill_threshold: usize,
157
158 pub compactor_concurrent_uploading_sst_count: Option<usize>,
159
160 pub compactor_max_overlap_sst_count: usize,
161
162 pub compactor_max_preload_meta_file_count: usize,
164
165 pub object_store_config: ObjectStoreConfig,
166 pub time_travel_version_cache_capacity: u64,
167 pub table_change_log_cache_capacity: u64,
168
169 pub iceberg_compaction_enable_validate: bool,
170 pub iceberg_compaction_max_record_batch_rows: usize,
171 pub iceberg_compaction_write_parquet_max_row_group_rows: usize,
172 pub iceberg_compaction_min_size_per_partition_mb: u32,
173 pub iceberg_compaction_max_file_count_per_partition: u32,
174 pub iceberg_compaction_target_binpack_group_size_mb: Option<u64>,
175 pub iceberg_compaction_min_group_size_mb: Option<u64>,
176 pub iceberg_compaction_min_group_file_count: Option<usize>,
177
178 pub iceberg_compaction_task_parallelism_ratio: f32,
180 pub iceberg_compaction_enable_heuristic_output_parallelism: bool,
182 pub iceberg_compaction_max_concurrent_closes: usize,
184 pub iceberg_compaction_enable_dynamic_size_estimation: bool,
186 pub iceberg_compaction_size_estimation_smoothing_factor: f64,
188 pub iceberg_compaction_pending_parallelism_budget_multiplier: f32,
190 pub iceberg_compaction_pull_interval_ms: u64,
192}
193
194impl Default for StorageOpts {
195 fn default() -> Self {
196 let c = RwConfig::default();
197 let p = system_params_for_test();
198 let s = extract_storage_memory_config(&c);
199 Self::from((&c, &p.into(), &s))
200 }
201}
202
203impl From<(&RwConfig, &SystemParamsReader, &StorageMemoryConfig)> for StorageOpts {
204 fn from((c, p, s): (&RwConfig, &SystemParamsReader, &StorageMemoryConfig)) -> Self {
205 let mut data_file_cache_throttle = c.storage.data_file_cache.throttle.clone();
206 if data_file_cache_throttle.write_throughput.is_none() {
207 data_file_cache_throttle = data_file_cache_throttle.with_write_throughput(
208 c.storage.data_file_cache.insert_rate_limit_mb * 1024 * 1024,
209 );
210 }
211 let mut meta_file_cache_throttle = c.storage.meta_file_cache.throttle.clone();
212 if meta_file_cache_throttle.write_throughput.is_none() {
213 meta_file_cache_throttle = meta_file_cache_throttle.with_write_throughput(
214 c.storage.meta_file_cache.insert_rate_limit_mb * 1024 * 1024,
215 );
216 }
217
218 Self {
219 parallel_compact_size_mb: p.parallel_compact_size_mb(),
220 sstable_size_mb: p.sstable_size_mb(),
221 min_sstable_size_mb: c.storage.min_sstable_size_mb,
222 block_size_kb: p.block_size_kb(),
223 bloom_false_positive: p.bloom_false_positive(),
224 share_buffers_sync_parallelism: c.storage.share_buffers_sync_parallelism,
225 share_buffer_compaction_worker_threads_number: c
226 .storage
227 .share_buffer_compaction_worker_threads_number,
228 shared_buffer_capacity_mb: s.shared_buffer_capacity_mb,
229 shared_buffer_flush_ratio: c.storage.shared_buffer_flush_ratio,
230 shared_buffer_min_batch_flush_size_mb: c.storage.shared_buffer_min_batch_flush_size_mb,
231 data_directory: p.data_directory().to_owned(),
232 write_conflict_detection_enabled: c.storage.write_conflict_detection_enabled,
233 block_cache_capacity_mb: s.block_cache_capacity_mb,
234 block_cache_shard_num: s.block_cache_shard_num,
235 block_cache_eviction_config: s.block_cache_eviction_config.clone(),
236 meta_cache_capacity_mb: s.meta_cache_capacity_mb,
237 meta_cache_shard_num: s.meta_cache_shard_num,
238 meta_cache_eviction_config: s.meta_cache_eviction_config.clone(),
239 prefetch_buffer_capacity_mb: s.prefetch_buffer_capacity_mb,
240 max_cached_recent_versions_number: c.storage.max_cached_recent_versions_number,
241 max_prefetch_block_number: c.storage.max_prefetch_block_number,
242 disable_remote_compactor: c.storage.disable_remote_compactor,
243 share_buffer_upload_concurrency: c.storage.share_buffer_upload_concurrency,
244 compactor_memory_limit_mb: s.compactor_memory_limit_mb,
245 sstable_id_remote_fetch_number: c.storage.sstable_id_remote_fetch_number,
246 min_sst_size_for_streaming_upload: c.storage.min_sst_size_for_streaming_upload,
247 max_concurrent_compaction_task_number: c.storage.max_concurrent_compaction_task_number,
248 max_version_pinning_duration_sec: c.storage.max_version_pinning_duration_sec,
249 data_file_cache_dir: c.storage.data_file_cache.dir.clone(),
250 data_file_cache_capacity_mb: c.storage.data_file_cache.capacity_mb,
251 data_file_cache_file_capacity_mb: c.storage.data_file_cache.file_capacity_mb,
252 data_file_cache_flushers: c.storage.data_file_cache.flushers,
253 data_file_cache_reclaimers: c.storage.data_file_cache.reclaimers,
254 data_file_cache_recover_mode: c.storage.data_file_cache.recover_mode,
255 data_file_cache_recover_concurrency: c.storage.data_file_cache.recover_concurrency,
256 data_file_cache_indexer_shards: c.storage.data_file_cache.indexer_shards,
257 data_file_cache_compression: c.storage.data_file_cache.compression,
258 data_file_cache_flush_buffer_threshold_mb: s.block_file_cache_flush_buffer_threshold_mb,
259 data_file_cache_fifo_probation_ratio: c.storage.data_file_cache.fifo_probation_ratio,
260 data_file_cache_blob_index_size_kb: c.storage.data_file_cache.blob_index_size_kb,
261 data_file_cache_runtime_config: c.storage.data_file_cache.runtime_config.clone(),
262 data_file_cache_throttle,
263 meta_file_cache_dir: c.storage.meta_file_cache.dir.clone(),
264 meta_file_cache_capacity_mb: c.storage.meta_file_cache.capacity_mb,
265 meta_file_cache_file_capacity_mb: c.storage.meta_file_cache.file_capacity_mb,
266 meta_file_cache_flushers: c.storage.meta_file_cache.flushers,
267 meta_file_cache_reclaimers: c.storage.meta_file_cache.reclaimers,
268 meta_file_cache_recover_mode: c.storage.meta_file_cache.recover_mode,
269 meta_file_cache_recover_concurrency: c.storage.meta_file_cache.recover_concurrency,
270 meta_file_cache_indexer_shards: c.storage.meta_file_cache.indexer_shards,
271 meta_file_cache_compression: c.storage.meta_file_cache.compression,
272 meta_file_cache_flush_buffer_threshold_mb: s.meta_file_cache_flush_buffer_threshold_mb,
273 meta_file_cache_fifo_probation_ratio: c.storage.meta_file_cache.fifo_probation_ratio,
274 meta_file_cache_blob_index_size_kb: c.storage.meta_file_cache.blob_index_size_kb,
275 meta_file_cache_runtime_config: c.storage.meta_file_cache.runtime_config.clone(),
276 meta_file_cache_throttle,
277 sst_skip_bloom_filter_in_serde: c.storage.sst_skip_bloom_filter_in_serde,
278 cache_refill_data_refill_levels: c.storage.cache_refill.data_refill_levels.clone(),
279 cache_refill_timeout_ms: c.storage.cache_refill.timeout_ms,
280 cache_refill_meta_refill_concurrency: c.storage.cache_refill.meta_refill_concurrency,
281 cache_refill_concurrency: c.storage.cache_refill.concurrency,
282 cache_refill_recent_filter_shards: c.storage.cache_refill.recent_filter_shards,
283 cache_refill_recent_filter_layers: c.storage.cache_refill.recent_filter_layers,
284 cache_refill_recent_filter_rotate_interval_ms: c
285 .storage
286 .cache_refill
287 .recent_filter_rotate_interval_ms,
288 cache_refill_unit: c.storage.cache_refill.unit,
289 cache_refill_threshold: c.storage.cache_refill.threshold,
290 cache_refill_skip_recent_filter: c.storage.cache_refill.skip_recent_filter,
291 max_preload_wait_time_mill: c.storage.max_preload_wait_time_mill,
292 compact_iter_recreate_timeout_ms: c.storage.compact_iter_recreate_timeout_ms,
293
294 max_preload_io_retry_times: c.storage.max_preload_io_retry_times,
295 backup_storage_url: p.backup_storage_url().to_owned(),
296 backup_storage_directory: p.backup_storage_directory().to_owned(),
297 compactor_max_sst_key_count: c.storage.compactor_max_sst_key_count,
298 compactor_max_task_multiplier: c.storage.compactor_max_task_multiplier,
299 compactor_max_sst_size: c.storage.compactor_max_sst_size,
300 enable_fast_compaction: c.storage.enable_fast_compaction,
301 check_compaction_result: c.storage.check_compaction_result,
302 mem_table_spill_threshold: c.storage.mem_table_spill_threshold,
303 object_store_config: c.storage.object_store.clone(),
304 compactor_fast_max_compact_delete_ratio: c
305 .storage
306 .compactor_fast_max_compact_delete_ratio,
307 compactor_fast_max_compact_task_size: c.storage.compactor_fast_max_compact_task_size,
308 compactor_iter_max_io_retry_times: c.storage.compactor_iter_max_io_retry_times,
309 shorten_block_meta_key_threshold: c.storage.shorten_block_meta_key_threshold,
310 compactor_concurrent_uploading_sst_count: c
311 .storage
312 .compactor_concurrent_uploading_sst_count,
313 time_travel_version_cache_capacity: c.storage.time_travel_version_cache_capacity,
314 table_change_log_cache_capacity: c.storage.table_change_log_cache_capacity,
315 compactor_max_overlap_sst_count: c.storage.compactor_max_overlap_sst_count,
316 compactor_max_preload_meta_file_count: c.storage.compactor_max_preload_meta_file_count,
317
318 iceberg_compaction_enable_validate: c.storage.iceberg_compaction_enable_validate,
319 iceberg_compaction_max_record_batch_rows: c
320 .storage
321 .iceberg_compaction_max_record_batch_rows,
322 #[allow(deprecated)]
323 iceberg_compaction_write_parquet_max_row_group_rows: c
324 .storage
325 .iceberg_compaction_write_parquet_max_row_group_rows,
326 iceberg_compaction_min_size_per_partition_mb: c
327 .storage
328 .iceberg_compaction_min_size_per_partition_mb,
329 iceberg_compaction_max_file_count_per_partition: c
330 .storage
331 .iceberg_compaction_max_file_count_per_partition,
332 iceberg_compaction_task_parallelism_ratio: c
333 .storage
334 .iceberg_compaction_task_parallelism_ratio,
335 iceberg_compaction_enable_heuristic_output_parallelism: c
336 .storage
337 .iceberg_compaction_enable_heuristic_output_parallelism,
338 iceberg_compaction_max_concurrent_closes: c
339 .storage
340 .iceberg_compaction_max_concurrent_closes,
341 iceberg_compaction_enable_dynamic_size_estimation: c
342 .storage
343 .iceberg_compaction_enable_dynamic_size_estimation,
344 iceberg_compaction_size_estimation_smoothing_factor: c
345 .storage
346 .iceberg_compaction_size_estimation_smoothing_factor,
347 iceberg_compaction_pending_parallelism_budget_multiplier: c
348 .storage
349 .iceberg_compaction_pending_parallelism_budget_multiplier,
350 iceberg_compaction_pull_interval_ms: c.storage.iceberg_compaction_pull_interval_ms,
351 iceberg_compaction_target_binpack_group_size_mb: c
352 .storage
353 .iceberg_compaction_target_binpack_group_size_mb,
354 iceberg_compaction_min_group_size_mb: c.storage.iceberg_compaction_min_group_size_mb,
355 iceberg_compaction_min_group_file_count: c
356 .storage
357 .iceberg_compaction_min_group_file_count,
358 vector_file_block_size_kb: c.storage.vector_file_block_size_kb,
359 vector_block_cache_capacity_mb: s.vector_block_cache_capacity_mb,
360 vector_block_cache_shard_num: s.vector_block_cache_shard_num,
361 vector_block_cache_eviction_config: s.vector_block_cache_eviction_config.clone(),
362 vector_meta_cache_capacity_mb: s.vector_meta_cache_capacity_mb,
363 vector_meta_cache_shard_num: s.vector_meta_cache_shard_num,
364 vector_meta_cache_eviction_config: s.vector_meta_cache_eviction_config.clone(),
365 }
366 }
367}