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

Code before:
            self.rocksdb.defaultcf.disable_write_stall = true;
            self.rocksdb.writecf.disable_write_stall = true;
            self.rocksdb.lockcf.disable_write_stall = true;
            self.rocksdb.raftcf.disable_write_stall = true;
        }
        // Fill in values for unspecified write stall configurations.

        macro_rules! fill_cf_opts {
            ($cf_opts:expr, $cfg:expr) => {
                // Automatically override `level0_slowdown_writes_trigger` if it is set too high,
                // to ensure that RocksDB's compaction speed-up mechanism can help avoid triggering flow control,
                // since RocksDB starts speed up compaction when the number of L0 files reaches this threshold.
                //
                // For the same reason, when `l0-file-threshold` is set to a higher value, we do **not** override it,
                // because we still want RocksDB's compaction speed-up mechanism to take effect—
                // allowing compaction to proceed more quickly and smoothly, leading to more stable performance
                // and avoiding issues like https://github.com/tikv/tikv/issues/18708.
                if $cfg.enable && $cf_opts.level0_slowdown_writes_trigger > $cfg.l0_files_threshold as i32 {
                    warn!(
                        "{}.level0-slowdown-writes-trigger is too large. Setting it to \
                        storage.flow-control.l0-files-threshold ({})",
                        stringify!($cf_opts), $cfg.l0_files_threshold
                    );
                    $cf_opts.level0_slowdown_writes_trigger = $cfg.l0_files_threshold as i32;
                }
                // Keep override for level0_stop_writes_trigger to ensure ingest_maybe_stall
                // integrates properly with flow control for correctness on SST ingestion
                if let Some(v) = &mut $cf_opts.level0_stop_writes_trigger {
                    if $cfg.enable && *v > $cfg.l0_files_threshold as i32 {
                        warn!(
                            "{}.level0-stop-writes-trigger is too large. Setting it to \
                            storage.flow-control.l0-files-threshold ({})",
                            stringify!($cf_opts), $cfg.l0_files_threshold
                        );
                        *v = $cfg.l0_files_threshold as i32;
                    }
                } else {
                    $cf_opts.level0_stop_writes_trigger =
                        Some($cfg.l0_files_threshold as i32);
                }
                // The reason for automatically overriding it is the same as for `level0_slowdown_writes_trigger`.
                if $cfg.enable && $cf_opts.soft_pending_compaction_bytes_limit.0 > $cfg.soft_pending_compaction_bytes_limit.0 {
                    warn!(
                        "{}.soft-pending-compaction-bytes-limit is too large. Setting it to \
                        storage.flow-control.soft-pending-compaction-bytes-limit ({})",
                        stringify!($cf_opts), $cfg.soft_pending_compaction_bytes_limit.0
                    );
                    $cf_opts.soft_pending_compaction_bytes_limit = $cfg.soft_pending_compaction_bytes_limit;
                }
                if let Some(v) = &mut $cf_opts.hard_pending_compaction_bytes_limit {
                    if $cfg.enable && v.0 > $cfg.hard_pending_compaction_bytes_limit.0 {

Review comment (performance):
nit: this may highlight their differences?
```suggestion
                // If unset, `level0_stop_writes_trigger` defaults to `l0_files_threshold` (unlike `level0_slowdown_writes_trigger`, which defaults to 20) to ensure ingest_maybe_stall
```

Code after:
        if expect_keepalive > self.server.grpc_keepalive_time.0 {
            return Err(format!(
                "grpc_keepalive_time is too small, it should not less than the double of \
                 raft tick interval (>= {})",
                duration_to_sec(expect_keepalive)
            )
            .into());
        }
        if self.raft_store.hibernate_regions && !self.cdc.hibernate_regions_compatible {
            warn!(
                "raftstore.hibernate-regions was enabled but cdc.hibernate-regions-compatible \
                was disabled, hibernate regions may be broken up if you want to deploy a cdc cluster"
            );
        }

        // Validate flow control and rocksdb write stall.
        if self.storage.flow_control.enable {
            self.rocksdb.defaultcf.disable_write_stall = true;
            self.rocksdb.writecf.disable_write_stall = true;
            self.rocksdb.lockcf.disable_write_stall = true;
            self.rocksdb.raftcf.disable_write_stall = true;
        }
        // Fill in values for unspecified write stall configurations.

        macro_rules! fill_cf_opts {
            ($cf_opts:expr, $cfg:expr) => {
                // Automatically override `level0_slowdown_writes_trigger` if it is set too high,
                // to ensure that RocksDB's compaction speed-up mechanism can help avoid triggering flow control,
                // since RocksDB starts speed up compaction when the number of L0 files reaches this threshold.
                //
                // For the same reason, when `l0-file-threshold` is set to a higher value, we do **not** override it,
                // because we still want RocksDB's compaction speed-up mechanism to take effect—
                // allowing compaction to proceed more quickly and smoothly, leading to more stable performance
                // and avoiding issues like https://github.com/tikv/tikv/issues/18708.
                if $cfg.enable && $cf_opts.level0_slowdown_writes_trigger > $cfg.l0_files_threshold as i32 {
                    warn!(
                        "{}.level0-slowdown-writes-trigger is too large. Setting it to \
                        storage.flow-control.l0-files-threshold ({})",
                        stringify!($cf_opts), $cfg.l0_files_threshold
                    );
                    $cf_opts.level0_slowdown_writes_trigger = $cfg.l0_files_threshold as i32;
                }
                // If unset, `level0_stop_writes_trigger` defaults to `l0_files_threshold`
                // (unlike `level0_slowdown_writes_trigger`, which defaults to 20)  to ensure ingest_maybe_stall
                // integrates properly with flow control for correctness on SST ingestion
                if let Some(v) = &mut $cf_opts.level0_stop_writes_trigger {
                    if $cfg.enable && *v > $cfg.l0_files_threshold as i32 {
                        warn!(
                            "{}.level0-stop-writes-trigger is too large. Setting it to \
                            storage.flow-control.l0-files-threshold ({})",
                            stringify!($cf_opts), $cfg.l0_files_threshold