Repository: risingwavelabs/risingwave
File: src/compute/src/memory/config.rs (Rust)

Code before:
        ((non_reserved_memory_bytes as f64 * default_compactor_memory_proportion).ceil() as usize) >> 20,
    );
    tracing::warn!("default_storage_memory_bytes={} max_storage_memory_bytes={} compactor_memory_limit_mb={}", default_storage_memory_bytes, max_storage_memory_bytes, compactor_memory_limit_mb);

    // Only if the all cache capacities are specified and their sum doesn't exceed the max allowed storage_memory_bytes, will we use them.
    // Other invalid combination of the cache capacities config will be ignored.
    let (
        config_block_cache_capacity_mb,
        config_meta_cache_capacity_mb,
        config_shared_buffer_capacity_mb,
    ) = match (
        storage_config.cache.block_cache_capacity_mb,
        storage_config.cache.meta_cache_capacity_mb,
        storage_config.shared_buffer_capacity_mb,
    ) {
        (
            Some(block_cache_capacity_mb),
            Some(meta_cache_capacity_mb),
            Some(shared_buffer_capacity_mb),
        ) => {
            let config_storage_memory_bytes =
                (block_cache_capacity_mb + meta_cache_capacity_mb + shared_buffer_capacity_mb + compactor_memory_limit_mb)
                    << 20;
            if config_storage_memory_bytes as f64 > max_storage_memory_bytes {
                tracing::warn!(
                    "config block_cache_capacity_mb {} + meta_cache_capacity_mb {} + shared_buffer_capacity_mb {}  + compactor_memory_limit_mb {} = {} exceeds allowed storage_memory_bytes {}. These configs will be ignored.",
                    block_cache_capacity_mb,
                    meta_cache_capacity_mb,
                    shared_buffer_capacity_mb,
                    compactor_memory_limit_mb,
                    convert(config_storage_memory_bytes as _),
                    convert(max_storage_memory_bytes as _)
                );
                (None, None, None)
            } else {
                (
                    Some(block_cache_capacity_mb),
                    Some(meta_cache_capacity_mb),
                    Some(shared_buffer_capacity_mb),
                )
            }
        }
        c => {
            tracing::warn!(
                "config (block_cache_capacity_mb, meta_cache_capacity_mb, shared_buffer_capacity_mb): {:?} should be set altogether. These configs will be ignored.",
                c
            );
            (None, None, None)
        }
    };


Review comment (performance):
There is an extra space in the format string before the plus sign. Change "shared_buffer_capacity_mb {}  +" to "shared_buffer_capacity_mb {} +" for consistency with the other fields.
```suggestion
                    "config block_cache_capacity_mb {} + meta_cache_capacity_mb {} + shared_buffer_capacity_mb {} + compactor_memory_limit_mb {} = {} exceeds allowed storage_memory_bytes {}. These configs will be ignored.",
```

Code after:
            )
        };

    let default_storage_memory_bytes =
        (non_reserved_memory_bytes as f64 * default_storage_memory_proportion).ceil();
    let max_storage_memory_bytes =
        (non_reserved_memory_bytes as f64 * STORAGE_MEMORY_MAX_PROPORTION).ceil();

    let compactor_memory_limit_mb = storage_config.compactor_memory_limit_mb.unwrap_or(
        ((non_reserved_memory_bytes as f64 * default_compactor_memory_proportion).ceil() as usize)
            >> 20,
    );
    tracing::debug!(
        "default_storage_memory_bytes={} max_storage_memory_bytes={} compactor_memory_limit_mb={}",
        default_storage_memory_bytes,
        max_storage_memory_bytes,
        compactor_memory_limit_mb
    );

    // Only if all cache capacities and compactor memory are specified and their sum doesn't exceed the max allowed storage_memory_bytes, will we use them.
    // Other invalid combinations of the cache capacities and compactor memory config will be ignored.
    let (
        config_block_cache_capacity_mb,
        config_meta_cache_capacity_mb,
        config_shared_buffer_capacity_mb,
    ) = match (
        storage_config.cache.block_cache_capacity_mb,
        storage_config.cache.meta_cache_capacity_mb,
        storage_config.shared_buffer_capacity_mb,
    ) {
        (
            Some(block_cache_capacity_mb),
            Some(meta_cache_capacity_mb),
            Some(shared_buffer_capacity_mb),
        ) => {
            let config_storage_memory_bytes = (block_cache_capacity_mb
                + meta_cache_capacity_mb
                + shared_buffer_capacity_mb
                + compactor_memory_limit_mb)
                << 20;
            if config_storage_memory_bytes as f64 > max_storage_memory_bytes {
                tracing::warn!(
                    "config block_cache_capacity_mb {} + meta_cache_capacity_mb {} + shared_buffer_capacity_mb {} + compactor_memory_limit_mb {} = {} exceeds allowed storage_memory_bytes {}. These configs will be ignored.",
                    block_cache_capacity_mb,
                    meta_cache_capacity_mb,
                    shared_buffer_capacity_mb,
                    compactor_memory_limit_mb,
                    convert(config_storage_memory_bytes as _),
                    convert(max_storage_memory_bytes as _)
                );
                (None, None, None)