Repository: tikv/tikv
File: src/config/mod.rs (Rust)

Code before:
        let file_size_limit = ReadableSize::mb(256);
        // Don't use too many memory.
        let temp_file_quota = total_mem / 16;
        let quota_size = (total_mem as f64 * 0.1).min(ReadableSize::mb(512).0 as _);
        // 2x of the max pending bytes. The extra buffer make us easier to keep all
        // files in memory.
        let preferred_cache_size = file_size_limit.0 * 2;
        let cache_size = ReadableSize(temp_file_quota.min(preferred_cache_size));
        Self {
            min_ts_interval: ReadableDuration::secs(10),
            max_flush_interval: ReadableDuration::minutes(3),
            // use at most 50% of vCPU by default
            num_threads: (cpu_num * 0.5).clamp(2.0, 12.0) as usize,
            enable: true,
            // TODO: may be use raft store directory
            temp_path: String::new(),
            file_size_limit,
            initial_scan_pending_memory_quota: ReadableSize(quota_size as _),
            initial_scan_rate_limit: ReadableSize::mb(60),
            initial_scan_concurrency: 6,
            temp_file_memory_quota: cache_size,
            s3_multi_part_size: ReadableSize::mb(5),
        }
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, OnlineConfig)]
#[serde(default)]
#[serde(rename_all = "kebab-case")]
pub struct CdcConfig {
    pub min_ts_interval: ReadableDuration,
    pub hibernate_regions_compatible: bool,
    // TODO(hi-rustin): Consider resizing the thread pool based on `incremental_scan_threads`.
    #[online_config(skip)]
    pub incremental_scan_threads: usize,
    // The number of scan tasks that is allowed to run concurrently.
    pub incremental_scan_concurrency: usize,
    // The number of scan tasks that is allowed to be created. In other words,
    // there will be at most `incremental_scan_concurrency_limit - incremental_scan_concurrency`
    // number of scan tasks that is waitting to run.
    pub incremental_scan_concurrency_limit: usize,
    /// Limit scan speed based on disk I/O traffic.
    pub incremental_scan_speed_limit: ReadableSize,
    /// Limit scan speed based on memory accesing traffic.
    #[doc(hidden)]
    pub incremental_fetch_speed_limit: ReadableSize,
    /// `TsFilter` can increase speed and decrease resource usage when
    /// incremental content is much less than total content. However in
    /// other cases, `TsFilter` can make performance worse because it needs
    /// to re-fetch old row values if they are required.
    ///

Review comment (suggestion):
To maintain maximum compatibility with existing behavior, we can increase the default part_size to 256 MB, so that in most cases the upload will be handled by a single PUT request.

Code after:
impl Default for BackupStreamConfig {
    fn default() -> Self {
        let cpu_num = SysQuota::cpu_cores_quota();
        let total_mem = SysQuota::memory_limit_in_bytes();
        let file_size_limit = ReadableSize::mb(256);
        // Don't use too many memory.
        let temp_file_quota = total_mem / 16;
        let quota_size = (total_mem as f64 * 0.1).min(ReadableSize::mb(512).0 as _);
        // 2x of the max pending bytes. The extra buffer make us easier to keep all
        // files in memory.
        let preferred_cache_size = file_size_limit.0 * 2;
        let cache_size = ReadableSize(temp_file_quota.min(preferred_cache_size));
        Self {
            min_ts_interval: ReadableDuration::secs(10),
            max_flush_interval: ReadableDuration::minutes(3),
            // use at most 50% of vCPU by default
            num_threads: (cpu_num * 0.5).clamp(2.0, 12.0) as usize,
            enable: true,
            // TODO: may be use raft store directory
            temp_path: String::new(),
            file_size_limit,
            initial_scan_pending_memory_quota: ReadableSize(quota_size as _),
            initial_scan_rate_limit: ReadableSize::mb(60),
            initial_scan_concurrency: 6,
            temp_file_memory_quota: cache_size,
            s3_multi_part_size: ReadableSize::mb(5),
        }
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, OnlineConfig)]
#[serde(default)]
#[serde(rename_all = "kebab-case")]
pub struct CdcConfig {
    pub min_ts_interval: ReadableDuration,
    pub hibernate_regions_compatible: bool,
    // TODO(hi-rustin): Consider resizing the thread pool based on `incremental_scan_threads`.
    #[online_config(skip)]
    pub incremental_scan_threads: usize,
    // The number of scan tasks that is allowed to run concurrently.
    pub incremental_scan_concurrency: usize,
    // The number of scan tasks that is allowed to be created. In other words,
    // there will be at most `incremental_scan_concurrency_limit - incremental_scan_concurrency`
    // number of scan tasks that is waitting to run.
    pub incremental_scan_concurrency_limit: usize,
    /// Limit scan speed based on disk I/O traffic.
    pub incremental_scan_speed_limit: ReadableSize,
    /// Limit scan speed based on memory accesing traffic.
    #[doc(hidden)]
    pub incremental_fetch_speed_limit: ReadableSize,
    /// `TsFilter` can increase speed and decrease resource usage when