risingwave_common/config/
storage.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use foyer::{
16    Compression, LfuConfig, LruConfig, RecoverMode, RuntimeOptions, S3FifoConfig, Throttle,
17};
18
19use super::*;
20
21/// The section `[storage]` in `risingwave.toml`.
22#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
23pub struct StorageConfig {
24    /// parallelism while syncing share buffers into L0 SST. Should NOT be 0.
25    #[serde(default = "default::storage::share_buffers_sync_parallelism")]
26    pub share_buffers_sync_parallelism: u32,
27
28    /// Worker threads number of dedicated tokio runtime for share buffer compaction. 0 means use
29    /// tokio's default value (number of CPU core).
30    #[serde(default = "default::storage::share_buffer_compaction_worker_threads_number")]
31    pub share_buffer_compaction_worker_threads_number: u32,
32
33    /// Configure the maximum shared buffer size in MB explicitly. Writes attempting to exceed the capacity
34    /// will stall until there is enough space. The overridden value will only be effective if:
35    /// 1. `block_cache_capacity_mb` and `meta_cache_capacity_mb` are also configured explicitly.
36    /// 2. `block_cache_capacity_mb` + `meta_cache_capacity_mb` + `meta_cache_capacity_mb` doesn't exceed 0.3 * non-reserved memory.
37    #[serde(default)]
38    pub shared_buffer_capacity_mb: Option<usize>,
39
40    /// The shared buffer will start flushing data to object when the ratio of memory usage to the
41    /// shared buffer capacity exceed such ratio.
42    #[serde(default = "default::storage::shared_buffer_flush_ratio")]
43    pub shared_buffer_flush_ratio: f32,
44
45    /// The minimum total flush size of shared buffer spill. When a shared buffer spilled is trigger,
46    /// the total flush size across multiple epochs should be at least higher than this size.
47    #[serde(default = "default::storage::shared_buffer_min_batch_flush_size_mb")]
48    pub shared_buffer_min_batch_flush_size_mb: usize,
49
50    /// The threshold for the number of immutable memtables to merge to a new imm.
51    #[serde(default = "default::storage::imm_merge_threshold")]
52    #[deprecated]
53    pub imm_merge_threshold: usize,
54
55    /// Whether to enable write conflict detection
56    #[serde(default = "default::storage::write_conflict_detection_enabled")]
57    pub write_conflict_detection_enabled: bool,
58
59    #[serde(default)]
60    #[config_doc(nested)]
61    pub cache: CacheConfig,
62
63    /// DEPRECATED: This config will be deprecated in the future version, use `storage.cache.block_cache_capacity_mb` instead.
64    #[serde(default)]
65    pub block_cache_capacity_mb: Option<usize>,
66
67    /// DEPRECATED: This config will be deprecated in the future version, use `storage.cache.meta_cache_capacity_mb` instead.
68    #[serde(default)]
69    pub meta_cache_capacity_mb: Option<usize>,
70
71    /// DEPRECATED: This config will be deprecated in the future version, use `storage.cache.block_cache_eviction.high_priority_ratio_in_percent` with `storage.cache.block_cache_eviction.algorithm = "Lru"` instead.
72    #[serde(default)]
73    pub high_priority_ratio_in_percent: Option<usize>,
74
75    /// max memory usage for large query
76    #[serde(default)]
77    pub prefetch_buffer_capacity_mb: Option<usize>,
78
79    #[serde(default = "default::storage::max_cached_recent_versions_number")]
80    pub max_cached_recent_versions_number: usize,
81
82    /// max prefetch block number
83    #[serde(default = "default::storage::max_prefetch_block_number")]
84    pub max_prefetch_block_number: usize,
85
86    #[serde(default = "default::storage::disable_remote_compactor")]
87    pub disable_remote_compactor: bool,
88
89    /// Number of tasks shared buffer can upload in parallel.
90    #[serde(default = "default::storage::share_buffer_upload_concurrency")]
91    pub share_buffer_upload_concurrency: usize,
92
93    #[serde(default)]
94    pub compactor_memory_limit_mb: Option<usize>,
95
96    /// Compactor calculates the maximum number of tasks that can be executed on the node based on
97    /// `worker_num` and `compactor_max_task_multiplier`.
98    /// `max_pull_task_count` = `worker_num` * `compactor_max_task_multiplier`
99    #[serde(default = "default::storage::compactor_max_task_multiplier")]
100    pub compactor_max_task_multiplier: f32,
101
102    /// The percentage of memory available when compactor is deployed separately.
103    /// `non_reserved_memory_bytes` = `system_memory_available_bytes` * `compactor_memory_available_proportion`
104    #[serde(default = "default::storage::compactor_memory_available_proportion")]
105    pub compactor_memory_available_proportion: f64,
106
107    /// Number of SST ids fetched from meta per RPC
108    #[serde(default = "default::storage::sstable_id_remote_fetch_number")]
109    pub sstable_id_remote_fetch_number: u32,
110
111    #[serde(default = "default::storage::min_sstable_size_mb")]
112    pub min_sstable_size_mb: u32,
113
114    #[serde(default)]
115    #[config_doc(nested)]
116    pub data_file_cache: FileCacheConfig,
117
118    #[serde(default)]
119    #[config_doc(nested)]
120    pub meta_file_cache: FileCacheConfig,
121
122    #[serde(default)]
123    #[config_doc(nested)]
124    pub cache_refill: CacheRefillConfig,
125
126    /// Whether to enable streaming upload for sstable.
127    #[serde(default = "default::storage::min_sst_size_for_streaming_upload")]
128    pub min_sst_size_for_streaming_upload: u64,
129
130    #[serde(default = "default::storage::max_concurrent_compaction_task_number")]
131    pub max_concurrent_compaction_task_number: u64,
132
133    #[serde(default = "default::storage::max_preload_wait_time_mill")]
134    pub max_preload_wait_time_mill: u64,
135
136    #[serde(default = "default::storage::max_version_pinning_duration_sec")]
137    pub max_version_pinning_duration_sec: u64,
138
139    #[serde(default = "default::storage::compactor_max_sst_key_count")]
140    pub compactor_max_sst_key_count: u64,
141    // DEPRECATED: This config will be deprecated in the future version, use `storage.compactor_iter_max_io_retry_times` instead.
142    #[serde(default = "default::storage::compact_iter_recreate_timeout_ms")]
143    pub compact_iter_recreate_timeout_ms: u64,
144    #[serde(default = "default::storage::compactor_max_sst_size")]
145    pub compactor_max_sst_size: u64,
146    #[serde(default = "default::storage::enable_fast_compaction")]
147    pub enable_fast_compaction: bool,
148    #[serde(default = "default::storage::check_compaction_result")]
149    pub check_compaction_result: bool,
150    #[serde(default = "default::storage::max_preload_io_retry_times")]
151    pub max_preload_io_retry_times: usize,
152    #[serde(default = "default::storage::compactor_fast_max_compact_delete_ratio")]
153    pub compactor_fast_max_compact_delete_ratio: u32,
154    #[serde(default = "default::storage::compactor_fast_max_compact_task_size")]
155    pub compactor_fast_max_compact_task_size: u64,
156    #[serde(default = "default::storage::compactor_iter_max_io_retry_times")]
157    pub compactor_iter_max_io_retry_times: usize,
158
159    /// Deprecated: The window size of table info statistic history.
160    #[serde(default = "default::storage::table_info_statistic_history_times")]
161    #[deprecated]
162    pub table_info_statistic_history_times: usize,
163
164    #[serde(default, flatten)]
165    #[config_doc(omitted)]
166    pub unrecognized: Unrecognized<Self>,
167
168    /// The spill threshold for mem table.
169    #[serde(default = "default::storage::mem_table_spill_threshold")]
170    pub mem_table_spill_threshold: usize,
171
172    /// The concurrent uploading number of `SSTables` of builder
173    #[serde(default = "default::storage::compactor_concurrent_uploading_sst_count")]
174    pub compactor_concurrent_uploading_sst_count: Option<usize>,
175
176    #[serde(default = "default::storage::compactor_max_overlap_sst_count")]
177    pub compactor_max_overlap_sst_count: usize,
178
179    /// The maximum number of meta files that can be preloaded.
180    /// If the number of meta files exceeds this value, the compactor will try to compute parallelism only through `SstableInfo`, no longer preloading `SstableMeta`.
181    /// This is to prevent the compactor from consuming too much memory, but it may cause the compactor to be less efficient.
182    #[serde(default = "default::storage::compactor_max_preload_meta_file_count")]
183    pub compactor_max_preload_meta_file_count: usize,
184
185    #[serde(default = "default::storage::vector_file_block_size_kb")]
186    pub vector_file_block_size_kb: usize,
187
188    /// Object storage configuration
189    /// 1. General configuration
190    /// 2. Some special configuration of Backend
191    /// 3. Retry and timeout configuration
192    #[serde(default)]
193    pub object_store: ObjectStoreConfig,
194
195    #[serde(default = "default::storage::time_travel_version_cache_capacity")]
196    pub time_travel_version_cache_capacity: u64,
197
198    // iceberg compaction
199    #[serde(default = "default::storage::iceberg_compaction_target_file_size_mb")]
200    pub iceberg_compaction_target_file_size_mb: u32,
201    #[serde(default = "default::storage::iceberg_compaction_enable_validate")]
202    pub iceberg_compaction_enable_validate: bool,
203    #[serde(default = "default::storage::iceberg_compaction_max_record_batch_rows")]
204    pub iceberg_compaction_max_record_batch_rows: usize,
205    #[serde(default = "default::storage::iceberg_compaction_min_size_per_partition_mb")]
206    pub iceberg_compaction_min_size_per_partition_mb: u32,
207    #[serde(default = "default::storage::iceberg_compaction_max_file_count_per_partition")]
208    pub iceberg_compaction_max_file_count_per_partition: u32,
209    #[serde(default = "default::storage::iceberg_compaction_write_parquet_max_row_group_rows")]
210    pub iceberg_compaction_write_parquet_max_row_group_rows: usize,
211
212    /// The ratio of iceberg compaction max parallelism to the number of CPU cores
213    #[serde(default = "default::storage::iceberg_compaction_task_parallelism_ratio")]
214    pub iceberg_compaction_task_parallelism_ratio: f32,
215    /// Whether to enable heuristic output parallelism in iceberg compaction.
216    #[serde(default = "default::storage::iceberg_compaction_enable_heuristic_output_parallelism")]
217    pub iceberg_compaction_enable_heuristic_output_parallelism: bool,
218    /// Maximum number of concurrent file close operations
219    #[serde(default = "default::storage::iceberg_compaction_max_concurrent_closes")]
220    pub iceberg_compaction_max_concurrent_closes: usize,
221    /// Whether to enable dynamic size estimation for iceberg compaction.
222    #[serde(default = "default::storage::iceberg_compaction_enable_dynamic_size_estimation")]
223    pub iceberg_compaction_enable_dynamic_size_estimation: bool,
224    /// The smoothing factor for size estimation in iceberg compaction.(default: 0.3)
225    #[serde(default = "default::storage::iceberg_compaction_size_estimation_smoothing_factor")]
226    pub iceberg_compaction_size_estimation_smoothing_factor: f64,
227    // For Small File Compaction
228    /// The threshold for small file compaction in MB.
229    #[serde(default = "default::storage::iceberg_compaction_small_file_threshold_mb")]
230    pub iceberg_compaction_small_file_threshold_mb: u32,
231    /// The maximum total size of tasks in small file compaction in MB.
232    #[serde(default = "default::storage::iceberg_compaction_max_task_total_size_mb")]
233    pub iceberg_compaction_max_task_total_size_mb: u32,
234}
235
236/// the section `[storage.cache]` in `risingwave.toml`.
237#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
238pub struct CacheConfig {
239    /// Configure the capacity of the block cache in MB explicitly.
240    /// The overridden value will only be effective if:
241    /// 1. `meta_cache_capacity_mb` and `shared_buffer_capacity_mb` are also configured explicitly.
242    /// 2. `block_cache_capacity_mb` + `meta_cache_capacity_mb` + `meta_cache_capacity_mb` doesn't exceed 0.3 * non-reserved memory.
243    #[serde(default)]
244    pub block_cache_capacity_mb: Option<usize>,
245
246    /// Configure the number of shards in the block cache explicitly.
247    /// If not set, the shard number will be determined automatically based on cache capacity.
248    #[serde(default)]
249    pub block_cache_shard_num: Option<usize>,
250
251    #[serde(default)]
252    #[config_doc(omitted)]
253    pub block_cache_eviction: CacheEvictionConfig,
254
255    /// Configure the capacity of the block cache in MB explicitly.
256    /// The overridden value will only be effective if:
257    /// 1. `block_cache_capacity_mb` and `shared_buffer_capacity_mb` are also configured explicitly.
258    /// 2. `block_cache_capacity_mb` + `meta_cache_capacity_mb` + `meta_cache_capacity_mb` doesn't exceed 0.3 * non-reserved memory.
259    #[serde(default)]
260    pub meta_cache_capacity_mb: Option<usize>,
261
262    /// Configure the number of shards in the meta cache explicitly.
263    /// If not set, the shard number will be determined automatically based on cache capacity.
264    #[serde(default)]
265    pub meta_cache_shard_num: Option<usize>,
266
267    #[serde(default)]
268    #[config_doc(omitted)]
269    pub meta_cache_eviction: CacheEvictionConfig,
270
271    #[serde(default = "default::storage::vector_block_cache_capacity_mb")]
272    pub vector_block_cache_capacity_mb: usize,
273    #[serde(default = "default::storage::vector_block_cache_shard_num")]
274    pub vector_block_cache_shard_num: usize,
275    #[serde(default)]
276    #[config_doc(omitted)]
277    pub vector_block_cache_eviction_config: CacheEvictionConfig,
278    #[serde(default = "default::storage::vector_meta_cache_capacity_mb")]
279    pub vector_meta_cache_capacity_mb: usize,
280    #[serde(default = "default::storage::vector_meta_cache_shard_num")]
281    pub vector_meta_cache_shard_num: usize,
282    #[serde(default)]
283    #[config_doc(omitted)]
284    pub vector_meta_cache_eviction_config: CacheEvictionConfig,
285}
286
287/// the section `[storage.cache.eviction]` in `risingwave.toml`.
288#[derive(Clone, Debug, Serialize, Deserialize)]
289#[serde(tag = "algorithm")]
290pub enum CacheEvictionConfig {
291    Lru {
292        high_priority_ratio_in_percent: Option<usize>,
293    },
294    Lfu {
295        window_capacity_ratio_in_percent: Option<usize>,
296        protected_capacity_ratio_in_percent: Option<usize>,
297        cmsketch_eps: Option<f64>,
298        cmsketch_confidence: Option<f64>,
299    },
300    S3Fifo {
301        small_queue_capacity_ratio_in_percent: Option<usize>,
302        ghost_queue_capacity_ratio_in_percent: Option<usize>,
303        small_to_main_freq_threshold: Option<u8>,
304    },
305}
306
307impl Default for CacheEvictionConfig {
308    fn default() -> Self {
309        Self::Lru {
310            high_priority_ratio_in_percent: None,
311        }
312    }
313}
314
315#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
316pub struct CacheRefillConfig {
317    /// `SSTable` levels to refill.
318    #[serde(default = "default::cache_refill::data_refill_levels")]
319    pub data_refill_levels: Vec<u32>,
320
321    /// Cache refill maximum timeout to apply version delta.
322    #[serde(default = "default::cache_refill::timeout_ms")]
323    pub timeout_ms: u64,
324
325    /// Inflight data cache refill tasks.
326    #[serde(default = "default::cache_refill::concurrency")]
327    pub concurrency: usize,
328
329    /// Block count that a data cache refill request fetches.
330    #[serde(default = "default::cache_refill::unit")]
331    pub unit: usize,
332
333    /// Data cache refill unit admission ratio.
334    ///
335    /// Only unit whose blocks are admitted above the ratio will be refilled.
336    #[serde(default = "default::cache_refill::threshold")]
337    pub threshold: f64,
338
339    /// Recent filter layer shards.
340    #[serde(default = "default::cache_refill::recent_filter_shards")]
341    pub recent_filter_shards: usize,
342
343    /// Recent filter layer count.
344    #[serde(default = "default::cache_refill::recent_filter_layers")]
345    pub recent_filter_layers: usize,
346
347    /// Recent filter layer rotate interval.
348    #[serde(default = "default::cache_refill::recent_filter_rotate_interval_ms")]
349    pub recent_filter_rotate_interval_ms: usize,
350
351    /// Skip check recent filter on data refill.
352    ///
353    /// This option is suitable for a single compute node or debugging.
354    #[serde(default = "default::cache_refill::skip_recent_filter")]
355    pub skip_recent_filter: bool,
356
357    #[serde(default, flatten)]
358    #[config_doc(omitted)]
359    pub unrecognized: Unrecognized<Self>,
360}
361
362/// The subsection `[storage.data_file_cache]` and `[storage.meta_file_cache]` in `risingwave.toml`.
363///
364/// It's put at [`StorageConfig::data_file_cache`] and  [`StorageConfig::meta_file_cache`].
365#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
366pub struct FileCacheConfig {
367    #[serde(default = "default::file_cache::dir")]
368    pub dir: String,
369
370    #[serde(default = "default::file_cache::capacity_mb")]
371    pub capacity_mb: usize,
372
373    #[serde(default = "default::file_cache::file_capacity_mb")]
374    pub file_capacity_mb: usize,
375
376    #[serde(default = "default::file_cache::flushers")]
377    pub flushers: usize,
378
379    #[serde(default = "default::file_cache::reclaimers")]
380    pub reclaimers: usize,
381
382    #[serde(default = "default::file_cache::recover_concurrency")]
383    pub recover_concurrency: usize,
384
385    /// Deprecated soon. Please use `throttle` to do I/O throttling instead.
386    #[serde(default = "default::file_cache::insert_rate_limit_mb")]
387    pub insert_rate_limit_mb: usize,
388
389    #[serde(default = "default::file_cache::indexer_shards")]
390    pub indexer_shards: usize,
391
392    #[serde(default = "default::file_cache::compression")]
393    pub compression: Compression,
394
395    #[serde(default = "default::file_cache::flush_buffer_threshold_mb")]
396    pub flush_buffer_threshold_mb: Option<usize>,
397
398    #[serde(default = "default::file_cache::throttle")]
399    pub throttle: Throttle,
400
401    #[serde(default = "default::file_cache::fifo_probation_ratio")]
402    pub fifo_probation_ratio: f64,
403
404    /// Recover mode.
405    ///
406    /// Options:
407    ///
408    /// - "None": Do not recover disk cache.
409    /// - "Quiet": Recover disk cache and skip errors.
410    /// - "Strict": Recover disk cache and panic on errors.
411    ///
412    /// More details, see [`RecoverMode::None`], [`RecoverMode::Quiet`] and [`RecoverMode::Strict`],
413    #[serde(default = "default::file_cache::recover_mode")]
414    pub recover_mode: RecoverMode,
415
416    #[serde(default = "default::file_cache::runtime_config")]
417    pub runtime_config: RuntimeOptions,
418
419    #[serde(default, flatten)]
420    #[config_doc(omitted)]
421    pub unrecognized: Unrecognized<Self>,
422}
423
424/// The subsections `[storage.object_store]`.
425#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde)]
426pub struct ObjectStoreConfig {
427    // alias is for backward compatibility
428    #[serde(
429        default = "default::object_store_config::set_atomic_write_dir",
430        alias = "object_store_set_atomic_write_dir"
431    )]
432    pub set_atomic_write_dir: bool,
433
434    /// Retry and timeout configuration
435    /// Description retry strategy driven by exponential back-off
436    /// Exposes the timeout and retries of each Object store interface. Therefore, the total timeout for each interface is determined based on the interface's timeout/retry configuration and the exponential back-off policy.
437    #[serde(default)]
438    pub retry: ObjectStoreRetryConfig,
439
440    /// Some special configuration of S3 Backend
441    #[serde(default)]
442    pub s3: S3ObjectStoreConfig,
443
444    // TODO: the following field will be deprecated after opendal is stabilized
445    #[serde(default = "default::object_store_config::opendal_upload_concurrency")]
446    pub opendal_upload_concurrency: usize,
447
448    // TODO: the following field will be deprecated after opendal is stabilized
449    #[serde(default)]
450    pub opendal_writer_abort_on_err: bool,
451
452    #[serde(default = "default::object_store_config::upload_part_size")]
453    pub upload_part_size: usize,
454}
455
456impl ObjectStoreConfig {
457    pub fn set_atomic_write_dir(&mut self) {
458        self.set_atomic_write_dir = true;
459    }
460}
461
462/// The subsections `[storage.object_store.s3]`.
463#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde)]
464pub struct S3ObjectStoreConfig {
465    // alias is for backward compatibility
466    #[serde(
467        default = "default::object_store_config::s3::keepalive_ms",
468        alias = "object_store_keepalive_ms"
469    )]
470    pub keepalive_ms: Option<u64>,
471    #[serde(
472        default = "default::object_store_config::s3::recv_buffer_size",
473        alias = "object_store_recv_buffer_size"
474    )]
475    pub recv_buffer_size: Option<usize>,
476    #[serde(
477        default = "default::object_store_config::s3::send_buffer_size",
478        alias = "object_store_send_buffer_size"
479    )]
480    pub send_buffer_size: Option<usize>,
481    #[serde(
482        default = "default::object_store_config::s3::nodelay",
483        alias = "object_store_nodelay"
484    )]
485    pub nodelay: Option<bool>,
486    /// For backwards compatibility, users should use `S3ObjectStoreDeveloperConfig` instead.
487    #[serde(default = "default::object_store_config::s3::developer::retry_unknown_service_error")]
488    pub retry_unknown_service_error: bool,
489    #[serde(default = "default::object_store_config::s3::identity_resolution_timeout_s")]
490    pub identity_resolution_timeout_s: u64,
491    #[serde(default)]
492    pub developer: S3ObjectStoreDeveloperConfig,
493}
494
495/// The subsections `[storage.object_store.s3.developer]`.
496#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde)]
497pub struct S3ObjectStoreDeveloperConfig {
498    /// Whether to retry s3 sdk error from which no error metadata is provided.
499    #[serde(
500        default = "default::object_store_config::s3::developer::retry_unknown_service_error",
501        alias = "object_store_retry_unknown_service_error"
502    )]
503    pub retry_unknown_service_error: bool,
504    /// An array of error codes that should be retried.
505    /// e.g. `["SlowDown", "TooManyRequests"]`
506    #[serde(
507        default = "default::object_store_config::s3::developer::retryable_service_error_codes",
508        alias = "object_store_retryable_service_error_codes"
509    )]
510    pub retryable_service_error_codes: Vec<String>,
511
512    // TODO: deprecate this config when we are completely deprecate aws sdk.
513    #[serde(default = "default::object_store_config::s3::developer::use_opendal")]
514    pub use_opendal: bool,
515}
516
517#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde)]
518pub struct ObjectStoreRetryConfig {
519    // A retry strategy driven by exponential back-off.
520    // The retry strategy is used for all object store operations.
521    /// Given a base duration for retry strategy in milliseconds.
522    #[serde(default = "default::object_store_config::object_store_req_backoff_interval_ms")]
523    pub req_backoff_interval_ms: u64,
524
525    /// The max delay interval for the retry strategy. No retry delay will be longer than this `Duration`.
526    #[serde(default = "default::object_store_config::object_store_req_backoff_max_delay_ms")]
527    pub req_backoff_max_delay_ms: u64,
528
529    /// A multiplicative factor that will be applied to the exponential back-off retry delay.
530    #[serde(default = "default::object_store_config::object_store_req_backoff_factor")]
531    pub req_backoff_factor: u64,
532
533    /// Maximum timeout for `upload` operation
534    #[serde(default = "default::object_store_config::object_store_upload_attempt_timeout_ms")]
535    pub upload_attempt_timeout_ms: u64,
536
537    /// Total counts of `upload` operation retries
538    #[serde(default = "default::object_store_config::object_store_upload_retry_attempts")]
539    pub upload_retry_attempts: usize,
540
541    /// Maximum timeout for `streaming_upload_init` and `streaming_upload`
542    #[serde(
543        default = "default::object_store_config::object_store_streaming_upload_attempt_timeout_ms"
544    )]
545    pub streaming_upload_attempt_timeout_ms: u64,
546
547    /// Total counts of `streaming_upload` operation retries
548    #[serde(
549        default = "default::object_store_config::object_store_streaming_upload_retry_attempts"
550    )]
551    pub streaming_upload_retry_attempts: usize,
552
553    /// Maximum timeout for `read` operation
554    #[serde(default = "default::object_store_config::object_store_read_attempt_timeout_ms")]
555    pub read_attempt_timeout_ms: u64,
556
557    /// Total counts of `read` operation retries
558    #[serde(default = "default::object_store_config::object_store_read_retry_attempts")]
559    pub read_retry_attempts: usize,
560
561    /// Maximum timeout for `streaming_read_init` and `streaming_read` operation
562    #[serde(
563        default = "default::object_store_config::object_store_streaming_read_attempt_timeout_ms"
564    )]
565    pub streaming_read_attempt_timeout_ms: u64,
566
567    /// Total counts of `streaming_read operation` retries
568    #[serde(default = "default::object_store_config::object_store_streaming_read_retry_attempts")]
569    pub streaming_read_retry_attempts: usize,
570
571    /// Maximum timeout for `metadata` operation
572    #[serde(default = "default::object_store_config::object_store_metadata_attempt_timeout_ms")]
573    pub metadata_attempt_timeout_ms: u64,
574
575    /// Total counts of `metadata` operation retries
576    #[serde(default = "default::object_store_config::object_store_metadata_retry_attempts")]
577    pub metadata_retry_attempts: usize,
578
579    /// Maximum timeout for `delete` operation
580    #[serde(default = "default::object_store_config::object_store_delete_attempt_timeout_ms")]
581    pub delete_attempt_timeout_ms: u64,
582
583    /// Total counts of `delete` operation retries
584    #[serde(default = "default::object_store_config::object_store_delete_retry_attempts")]
585    pub delete_retry_attempts: usize,
586
587    /// Maximum timeout for `delete_object` operation
588    #[serde(
589        default = "default::object_store_config::object_store_delete_objects_attempt_timeout_ms"
590    )]
591    pub delete_objects_attempt_timeout_ms: u64,
592
593    /// Total counts of `delete_object` operation retries
594    #[serde(default = "default::object_store_config::object_store_delete_objects_retry_attempts")]
595    pub delete_objects_retry_attempts: usize,
596
597    /// Maximum timeout for `list` operation
598    #[serde(default = "default::object_store_config::object_store_list_attempt_timeout_ms")]
599    pub list_attempt_timeout_ms: u64,
600
601    /// Total counts of `list` operation retries
602    #[serde(default = "default::object_store_config::object_store_list_retry_attempts")]
603    pub list_retry_attempts: usize,
604}
605
606#[derive(Debug, Clone)]
607pub enum EvictionConfig {
608    Lru(LruConfig),
609    Lfu(LfuConfig),
610    S3Fifo(S3FifoConfig),
611}
612
613impl EvictionConfig {
614    pub fn for_test() -> Self {
615        Self::Lru(LruConfig {
616            high_priority_pool_ratio: 0.0,
617        })
618    }
619}
620
621impl From<EvictionConfig> for foyer::EvictionConfig {
622    fn from(value: EvictionConfig) -> Self {
623        match value {
624            EvictionConfig::Lru(lru) => foyer::EvictionConfig::Lru(lru),
625            EvictionConfig::Lfu(lfu) => foyer::EvictionConfig::Lfu(lfu),
626            EvictionConfig::S3Fifo(s3fifo) => foyer::EvictionConfig::S3Fifo(s3fifo),
627        }
628    }
629}
630
631pub struct StorageMemoryConfig {
632    pub block_cache_capacity_mb: usize,
633    pub block_cache_shard_num: usize,
634    pub meta_cache_capacity_mb: usize,
635    pub meta_cache_shard_num: usize,
636    pub vector_block_cache_capacity_mb: usize,
637    pub vector_block_cache_shard_num: usize,
638    pub vector_meta_cache_capacity_mb: usize,
639    pub vector_meta_cache_shard_num: usize,
640    pub shared_buffer_capacity_mb: usize,
641    pub compactor_memory_limit_mb: usize,
642    pub prefetch_buffer_capacity_mb: usize,
643    pub block_cache_eviction_config: EvictionConfig,
644    pub meta_cache_eviction_config: EvictionConfig,
645    pub vector_block_cache_eviction_config: EvictionConfig,
646    pub vector_meta_cache_eviction_config: EvictionConfig,
647    pub block_file_cache_flush_buffer_threshold_mb: usize,
648    pub meta_file_cache_flush_buffer_threshold_mb: usize,
649}
650
651pub fn extract_storage_memory_config(s: &RwConfig) -> StorageMemoryConfig {
652    let block_cache_capacity_mb = s.storage.cache.block_cache_capacity_mb.unwrap_or(
653        // adapt to old version
654        s.storage
655            .block_cache_capacity_mb
656            .unwrap_or(default::storage::block_cache_capacity_mb()),
657    );
658    let meta_cache_capacity_mb = s.storage.cache.meta_cache_capacity_mb.unwrap_or(
659        // adapt to old version
660        s.storage
661            .block_cache_capacity_mb
662            .unwrap_or(default::storage::meta_cache_capacity_mb()),
663    );
664    let shared_buffer_capacity_mb = s
665        .storage
666        .shared_buffer_capacity_mb
667        .unwrap_or(default::storage::shared_buffer_capacity_mb());
668    let meta_cache_shard_num = s.storage.cache.meta_cache_shard_num.unwrap_or_else(|| {
669        let mut shard_bits = MAX_META_CACHE_SHARD_BITS;
670        while (meta_cache_capacity_mb >> shard_bits) < MIN_BUFFER_SIZE_PER_SHARD && shard_bits > 0 {
671            shard_bits -= 1;
672        }
673        shard_bits
674    });
675    let block_cache_shard_num = s.storage.cache.block_cache_shard_num.unwrap_or_else(|| {
676        let mut shard_bits = MAX_BLOCK_CACHE_SHARD_BITS;
677        while (block_cache_capacity_mb >> shard_bits) < MIN_BUFFER_SIZE_PER_SHARD && shard_bits > 0
678        {
679            shard_bits -= 1;
680        }
681        shard_bits
682    });
683    let compactor_memory_limit_mb = s
684        .storage
685        .compactor_memory_limit_mb
686        .unwrap_or(default::storage::compactor_memory_limit_mb());
687
688    let get_eviction_config = |c: &CacheEvictionConfig| {
689        match c {
690            CacheEvictionConfig::Lru {
691                high_priority_ratio_in_percent,
692            } => EvictionConfig::Lru(LruConfig {
693                high_priority_pool_ratio: high_priority_ratio_in_percent.unwrap_or(
694                    // adapt to old version
695                    s.storage
696                        .high_priority_ratio_in_percent
697                        .unwrap_or(default::storage::high_priority_ratio_in_percent()),
698                ) as f64
699                    / 100.0,
700            }),
701            CacheEvictionConfig::Lfu {
702                window_capacity_ratio_in_percent,
703                protected_capacity_ratio_in_percent,
704                cmsketch_eps,
705                cmsketch_confidence,
706            } => EvictionConfig::Lfu(LfuConfig {
707                window_capacity_ratio: window_capacity_ratio_in_percent
708                    .unwrap_or(default::storage::window_capacity_ratio_in_percent())
709                    as f64
710                    / 100.0,
711                protected_capacity_ratio: protected_capacity_ratio_in_percent
712                    .unwrap_or(default::storage::protected_capacity_ratio_in_percent())
713                    as f64
714                    / 100.0,
715                cmsketch_eps: cmsketch_eps.unwrap_or(default::storage::cmsketch_eps()),
716                cmsketch_confidence: cmsketch_confidence
717                    .unwrap_or(default::storage::cmsketch_confidence()),
718            }),
719            CacheEvictionConfig::S3Fifo {
720                small_queue_capacity_ratio_in_percent,
721                ghost_queue_capacity_ratio_in_percent,
722                small_to_main_freq_threshold,
723            } => EvictionConfig::S3Fifo(S3FifoConfig {
724                small_queue_capacity_ratio: small_queue_capacity_ratio_in_percent
725                    .unwrap_or(default::storage::small_queue_capacity_ratio_in_percent())
726                    as f64
727                    / 100.0,
728                ghost_queue_capacity_ratio: ghost_queue_capacity_ratio_in_percent
729                    .unwrap_or(default::storage::ghost_queue_capacity_ratio_in_percent())
730                    as f64
731                    / 100.0,
732                small_to_main_freq_threshold: small_to_main_freq_threshold
733                    .unwrap_or(default::storage::small_to_main_freq_threshold()),
734            }),
735        }
736    };
737
738    let block_cache_eviction_config = get_eviction_config(&s.storage.cache.block_cache_eviction);
739    let meta_cache_eviction_config = get_eviction_config(&s.storage.cache.meta_cache_eviction);
740    let vector_block_cache_eviction_config =
741        get_eviction_config(&s.storage.cache.vector_block_cache_eviction_config);
742    let vector_meta_cache_eviction_config =
743        get_eviction_config(&s.storage.cache.vector_meta_cache_eviction_config);
744
745    let prefetch_buffer_capacity_mb =
746        s.storage
747            .shared_buffer_capacity_mb
748            .unwrap_or(match &block_cache_eviction_config {
749                EvictionConfig::Lru(lru) => {
750                    ((1.0 - lru.high_priority_pool_ratio) * block_cache_capacity_mb as f64) as usize
751                }
752                EvictionConfig::Lfu(lfu) => {
753                    ((1.0 - lfu.protected_capacity_ratio) * block_cache_capacity_mb as f64) as usize
754                }
755                EvictionConfig::S3Fifo(s3fifo) => {
756                    (s3fifo.small_queue_capacity_ratio * block_cache_capacity_mb as f64) as usize
757                }
758            });
759
760    let block_file_cache_flush_buffer_threshold_mb = s
761        .storage
762        .data_file_cache
763        .flush_buffer_threshold_mb
764        .unwrap_or(default::storage::block_file_cache_flush_buffer_threshold_mb());
765    let meta_file_cache_flush_buffer_threshold_mb = s
766        .storage
767        .meta_file_cache
768        .flush_buffer_threshold_mb
769        .unwrap_or(default::storage::block_file_cache_flush_buffer_threshold_mb());
770
771    StorageMemoryConfig {
772        block_cache_capacity_mb,
773        block_cache_shard_num,
774        meta_cache_capacity_mb,
775        meta_cache_shard_num,
776        vector_block_cache_capacity_mb: s.storage.cache.vector_block_cache_capacity_mb,
777        vector_block_cache_shard_num: s.storage.cache.vector_block_cache_shard_num,
778        vector_meta_cache_capacity_mb: s.storage.cache.vector_meta_cache_capacity_mb,
779        vector_meta_cache_shard_num: s.storage.cache.vector_meta_cache_shard_num,
780        shared_buffer_capacity_mb,
781        compactor_memory_limit_mb,
782        prefetch_buffer_capacity_mb,
783        block_cache_eviction_config,
784        meta_cache_eviction_config,
785        vector_block_cache_eviction_config,
786        vector_meta_cache_eviction_config,
787        block_file_cache_flush_buffer_threshold_mb,
788        meta_file_cache_flush_buffer_threshold_mb,
789    }
790}
791
792pub mod default {
793
794    pub mod storage {
795        pub fn share_buffers_sync_parallelism() -> u32 {
796            1
797        }
798
799        pub fn share_buffer_compaction_worker_threads_number() -> u32 {
800            4
801        }
802
803        pub fn shared_buffer_capacity_mb() -> usize {
804            1024
805        }
806
807        pub fn shared_buffer_flush_ratio() -> f32 {
808            0.8
809        }
810
811        pub fn shared_buffer_min_batch_flush_size_mb() -> usize {
812            800
813        }
814
815        pub fn imm_merge_threshold() -> usize {
816            0 // disable
817        }
818
819        pub fn write_conflict_detection_enabled() -> bool {
820            cfg!(debug_assertions)
821        }
822
823        pub fn max_cached_recent_versions_number() -> usize {
824            60
825        }
826
827        pub fn block_cache_capacity_mb() -> usize {
828            512
829        }
830
831        pub fn high_priority_ratio_in_percent() -> usize {
832            70
833        }
834
835        pub fn window_capacity_ratio_in_percent() -> usize {
836            10
837        }
838
839        pub fn protected_capacity_ratio_in_percent() -> usize {
840            80
841        }
842
843        pub fn cmsketch_eps() -> f64 {
844            0.002
845        }
846
847        pub fn cmsketch_confidence() -> f64 {
848            0.95
849        }
850
851        pub fn small_queue_capacity_ratio_in_percent() -> usize {
852            10
853        }
854
855        pub fn ghost_queue_capacity_ratio_in_percent() -> usize {
856            1000
857        }
858
859        pub fn small_to_main_freq_threshold() -> u8 {
860            1
861        }
862
863        pub fn meta_cache_capacity_mb() -> usize {
864            128
865        }
866
867        pub fn disable_remote_compactor() -> bool {
868            false
869        }
870
871        pub fn share_buffer_upload_concurrency() -> usize {
872            8
873        }
874
875        pub fn compactor_memory_limit_mb() -> usize {
876            512
877        }
878
879        pub fn compactor_max_task_multiplier() -> f32 {
880            match std::env::var("RW_COMPACTOR_MODE")
881                .unwrap_or_default()
882                .as_str()
883            {
884                mode if mode.contains("iceberg") => 12.0000,
885                _ => 3.0000,
886            }
887        }
888
889        pub fn compactor_memory_available_proportion() -> f64 {
890            0.8
891        }
892
893        pub fn sstable_id_remote_fetch_number() -> u32 {
894            10
895        }
896
897        pub fn min_sstable_size_mb() -> u32 {
898            32
899        }
900
901        pub fn min_sst_size_for_streaming_upload() -> u64 {
902            // 32MB
903            32 * 1024 * 1024
904        }
905
906        pub fn max_concurrent_compaction_task_number() -> u64 {
907            16
908        }
909
910        pub fn max_preload_wait_time_mill() -> u64 {
911            0
912        }
913
914        pub fn max_version_pinning_duration_sec() -> u64 {
915            3 * 3600
916        }
917
918        pub fn compactor_max_sst_key_count() -> u64 {
919            2 * 1024 * 1024 // 200w
920        }
921
922        pub fn compact_iter_recreate_timeout_ms() -> u64 {
923            10 * 60 * 1000
924        }
925
926        pub fn compactor_iter_max_io_retry_times() -> usize {
927            8
928        }
929
930        pub fn compactor_max_sst_size() -> u64 {
931            512 * 1024 * 1024 // 512m
932        }
933
934        pub fn enable_fast_compaction() -> bool {
935            true
936        }
937
938        pub fn check_compaction_result() -> bool {
939            false
940        }
941
942        pub fn max_preload_io_retry_times() -> usize {
943            3
944        }
945
946        pub fn mem_table_spill_threshold() -> usize {
947            4 << 20
948        }
949
950        pub fn compactor_fast_max_compact_delete_ratio() -> u32 {
951            40
952        }
953
954        pub fn compactor_fast_max_compact_task_size() -> u64 {
955            2 * 1024 * 1024 * 1024 // 2g
956        }
957
958        pub fn max_prefetch_block_number() -> usize {
959            16
960        }
961
962        pub fn compactor_concurrent_uploading_sst_count() -> Option<usize> {
963            None
964        }
965
966        pub fn compactor_max_overlap_sst_count() -> usize {
967            64
968        }
969
970        pub fn compactor_max_preload_meta_file_count() -> usize {
971            32
972        }
973
974        pub fn vector_file_block_size_kb() -> usize {
975            1024
976        }
977
978        pub fn vector_block_cache_capacity_mb() -> usize {
979            16
980        }
981
982        pub fn vector_block_cache_shard_num() -> usize {
983            16
984        }
985
986        pub fn vector_meta_cache_capacity_mb() -> usize {
987            16
988        }
989
990        pub fn vector_meta_cache_shard_num() -> usize {
991            16
992        }
993
994        // deprecated
995        pub fn table_info_statistic_history_times() -> usize {
996            240
997        }
998
999        pub fn block_file_cache_flush_buffer_threshold_mb() -> usize {
1000            256
1001        }
1002
1003        pub fn meta_file_cache_flush_buffer_threshold_mb() -> usize {
1004            64
1005        }
1006
1007        pub fn time_travel_version_cache_capacity() -> u64 {
1008            10
1009        }
1010
1011        pub fn iceberg_compaction_target_file_size_mb() -> u32 {
1012            1024
1013        }
1014
1015        pub fn iceberg_compaction_enable_validate() -> bool {
1016            false
1017        }
1018
1019        pub fn iceberg_compaction_max_record_batch_rows() -> usize {
1020            1024
1021        }
1022
1023        pub fn iceberg_compaction_write_parquet_max_row_group_rows() -> usize {
1024            1024 * 100 // 100k
1025        }
1026
1027        pub fn iceberg_compaction_min_size_per_partition_mb() -> u32 {
1028            1024
1029        }
1030
1031        pub fn iceberg_compaction_max_file_count_per_partition() -> u32 {
1032            32
1033        }
1034
1035        pub fn iceberg_compaction_task_parallelism_ratio() -> f32 {
1036            4.0
1037        }
1038
1039        pub fn iceberg_compaction_enable_heuristic_output_parallelism() -> bool {
1040            false
1041        }
1042
1043        pub fn iceberg_compaction_max_concurrent_closes() -> usize {
1044            8
1045        }
1046
1047        pub fn iceberg_compaction_enable_dynamic_size_estimation() -> bool {
1048            true
1049        }
1050
1051        pub fn iceberg_compaction_size_estimation_smoothing_factor() -> f64 {
1052            0.3
1053        }
1054
1055        pub fn iceberg_compaction_small_file_threshold_mb() -> u32 {
1056            32
1057        }
1058
1059        pub fn iceberg_compaction_max_task_total_size_mb() -> u32 {
1060            50 * 1024 // 50GB
1061        }
1062    }
1063
1064    pub mod file_cache {
1065        use std::num::NonZeroUsize;
1066
1067        use foyer::{Compression, RecoverMode, RuntimeOptions, Throttle, TokioRuntimeOptions};
1068
1069        pub fn dir() -> String {
1070            "".to_owned()
1071        }
1072
1073        pub fn capacity_mb() -> usize {
1074            1024
1075        }
1076
1077        pub fn file_capacity_mb() -> usize {
1078            64
1079        }
1080
1081        pub fn flushers() -> usize {
1082            4
1083        }
1084
1085        pub fn reclaimers() -> usize {
1086            4
1087        }
1088
1089        pub fn recover_concurrency() -> usize {
1090            8
1091        }
1092
1093        pub fn insert_rate_limit_mb() -> usize {
1094            0
1095        }
1096
1097        pub fn indexer_shards() -> usize {
1098            64
1099        }
1100
1101        pub fn compression() -> Compression {
1102            Compression::None
1103        }
1104
1105        pub fn flush_buffer_threshold_mb() -> Option<usize> {
1106            None
1107        }
1108
1109        pub fn fifo_probation_ratio() -> f64 {
1110            0.1
1111        }
1112
1113        pub fn recover_mode() -> RecoverMode {
1114            RecoverMode::Quiet
1115        }
1116
1117        pub fn runtime_config() -> RuntimeOptions {
1118            RuntimeOptions::Unified(TokioRuntimeOptions::default())
1119        }
1120
1121        pub fn throttle() -> Throttle {
1122            Throttle::new()
1123                .with_iops_counter(foyer::IopsCounter::PerIoSize(
1124                    NonZeroUsize::new(128 * 1024).unwrap(),
1125                ))
1126                .with_read_iops(100000)
1127                .with_write_iops(100000)
1128                .with_write_throughput(1024 * 1024 * 1024)
1129                .with_read_throughput(1024 * 1024 * 1024)
1130        }
1131    }
1132
1133    pub mod cache_refill {
1134        pub fn data_refill_levels() -> Vec<u32> {
1135            vec![]
1136        }
1137
1138        pub fn timeout_ms() -> u64 {
1139            6000
1140        }
1141
1142        pub fn concurrency() -> usize {
1143            10
1144        }
1145
1146        pub fn unit() -> usize {
1147            64
1148        }
1149
1150        pub fn threshold() -> f64 {
1151            0.5
1152        }
1153
1154        pub fn recent_filter_shards() -> usize {
1155            16
1156        }
1157
1158        pub fn recent_filter_layers() -> usize {
1159            6
1160        }
1161
1162        pub fn recent_filter_rotate_interval_ms() -> usize {
1163            10000
1164        }
1165
1166        pub fn skip_recent_filter() -> bool {
1167            false
1168        }
1169    }
1170
1171    pub mod object_store_config {
1172        const DEFAULT_REQ_BACKOFF_INTERVAL_MS: u64 = 1000; // 1s
1173        const DEFAULT_REQ_BACKOFF_MAX_DELAY_MS: u64 = 10 * 1000; // 10s
1174        const DEFAULT_REQ_MAX_RETRY_ATTEMPTS: usize = 3;
1175
1176        pub fn set_atomic_write_dir() -> bool {
1177            false
1178        }
1179
1180        pub fn object_store_req_backoff_interval_ms() -> u64 {
1181            DEFAULT_REQ_BACKOFF_INTERVAL_MS
1182        }
1183
1184        pub fn object_store_req_backoff_max_delay_ms() -> u64 {
1185            DEFAULT_REQ_BACKOFF_MAX_DELAY_MS // 10s
1186        }
1187
1188        pub fn object_store_req_backoff_factor() -> u64 {
1189            2
1190        }
1191
1192        pub fn object_store_upload_attempt_timeout_ms() -> u64 {
1193            8 * 1000 // 8s
1194        }
1195
1196        pub fn object_store_upload_retry_attempts() -> usize {
1197            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1198        }
1199
1200        // init + upload_part + finish
1201        pub fn object_store_streaming_upload_attempt_timeout_ms() -> u64 {
1202            5 * 1000 // 5s
1203        }
1204
1205        pub fn object_store_streaming_upload_retry_attempts() -> usize {
1206            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1207        }
1208
1209        // tips: depend on block_size
1210        pub fn object_store_read_attempt_timeout_ms() -> u64 {
1211            8 * 1000 // 8s
1212        }
1213
1214        pub fn object_store_read_retry_attempts() -> usize {
1215            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1216        }
1217
1218        pub fn object_store_streaming_read_attempt_timeout_ms() -> u64 {
1219            3 * 1000 // 3s
1220        }
1221
1222        pub fn object_store_streaming_read_retry_attempts() -> usize {
1223            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1224        }
1225
1226        pub fn object_store_metadata_attempt_timeout_ms() -> u64 {
1227            60 * 1000 // 1min
1228        }
1229
1230        pub fn object_store_metadata_retry_attempts() -> usize {
1231            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1232        }
1233
1234        pub fn object_store_delete_attempt_timeout_ms() -> u64 {
1235            5 * 1000
1236        }
1237
1238        pub fn object_store_delete_retry_attempts() -> usize {
1239            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1240        }
1241
1242        // tips: depend on batch size
1243        pub fn object_store_delete_objects_attempt_timeout_ms() -> u64 {
1244            5 * 1000
1245        }
1246
1247        pub fn object_store_delete_objects_retry_attempts() -> usize {
1248            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1249        }
1250
1251        pub fn object_store_list_attempt_timeout_ms() -> u64 {
1252            10 * 60 * 1000
1253        }
1254
1255        pub fn object_store_list_retry_attempts() -> usize {
1256            DEFAULT_REQ_MAX_RETRY_ATTEMPTS
1257        }
1258
1259        pub fn opendal_upload_concurrency() -> usize {
1260            256
1261        }
1262
1263        pub fn upload_part_size() -> usize {
1264            // 16m
1265            16 * 1024 * 1024
1266        }
1267
1268        pub mod s3 {
1269            const DEFAULT_IDENTITY_RESOLUTION_TIMEOUT_S: u64 = 5;
1270
1271            const DEFAULT_KEEPALIVE_MS: u64 = 600 * 1000; // 10min
1272
1273            pub fn keepalive_ms() -> Option<u64> {
1274                Some(DEFAULT_KEEPALIVE_MS) // 10min
1275            }
1276
1277            pub fn recv_buffer_size() -> Option<usize> {
1278                Some(1 << 21) // 2m
1279            }
1280
1281            pub fn send_buffer_size() -> Option<usize> {
1282                None
1283            }
1284
1285            pub fn nodelay() -> Option<bool> {
1286                Some(true)
1287            }
1288
1289            pub fn identity_resolution_timeout_s() -> u64 {
1290                DEFAULT_IDENTITY_RESOLUTION_TIMEOUT_S
1291            }
1292
1293            pub mod developer {
1294                pub fn retry_unknown_service_error() -> bool {
1295                    false
1296                }
1297
1298                pub fn retryable_service_error_codes() -> Vec<String> {
1299                    vec!["SlowDown".into(), "TooManyRequests".into()]
1300                }
1301
1302                pub fn use_opendal() -> bool {
1303                    true
1304                }
1305            }
1306        }
1307    }
1308}