add DEFAULT_HEAL_OBJECT_SELECT_PROB

This commit is contained in:
weisd
2025-12-17 11:03:54 +08:00
parent 6466cdbc54
commit c0cdad2192
2 changed files with 20 additions and 2 deletions

View File

@@ -86,3 +86,18 @@ pub const DEFAULT_HEAL_TASK_TIMEOUT_SECS: u64 = 300; // 5 minutes
/// - Rationale: This default concurrency limit helps balance healing speed with resource usage, preventing system overload.
/// - Adjustments: Users may modify this value via the `RUSTFS_HEAL_MAX_CONCURRENT_HEALS` environment variable based on their system capacity and expected heal workload.
pub const DEFAULT_HEAL_MAX_CONCURRENT_HEALS: usize = 4;
/// Environment variable name that specifies the heal object select probability.
/// - Purpose: Control the probability of selecting objects for healing operations.
/// - Unit: integer probability value.
/// - Valid values: any positive integer.
/// - Semantics: Higher values increase the likelihood of object selection for healing; tune according to healing aggressiveness and system capacity.
/// - Example: `export RUSTFS_HEAL_OBJECT_SELECT_PROB=1024`
/// - Note: This probability affects how frequently objects are selected for background healing operations.
pub const ENV_HEAL_OBJECT_SELECT_PROB: &str = "RUSTFS_HEAL_OBJECT_SELECT_PROB";
/// Default heal object select probability if not specified in the environment variable.
/// - Value: 10.
/// - Rationale: This default provides a conservative selection rate for healing operations.
/// - Adjustments: Users may modify this value via the `RUSTFS_HEAL_OBJECT_SELECT_PROB` environment variable based on their healing requirements and system performance.
pub const DEFAULT_HEAL_OBJECT_SELECT_PROB: u32 = 1024;

View File

@@ -24,6 +24,7 @@ use crate::metrics::{UpdateCurrentPathFn, current_path_updater};
use crate::scanner_io::ScannerIODisk as _;
use rustfs_common::heal_channel::{HEAL_DELETE_DANGLING, HealChannelRequest, HealOpts, HealScanMode, send_heal_request};
use rustfs_common::metrics::IlmAction;
use rustfs_config::{DEFAULT_HEAL_OBJECT_SELECT_PROB, ENV_HEAL_OBJECT_SELECT_PROB};
use rustfs_ecstore::StorageAPI;
use rustfs_ecstore::bucket::lifecycle::bucket_lifecycle_audit::LcEventSrc;
use rustfs_ecstore::bucket::lifecycle::bucket_lifecycle_ops::apply_expiry_rule;
@@ -58,7 +59,9 @@ const DATA_SCANNER_COMPACT_LEAST_OBJECT: usize = 500;
const DATA_SCANNER_COMPACT_AT_CHILDREN: usize = 10000;
const DATA_SCANNER_COMPACT_AT_FOLDERS: usize = DATA_SCANNER_COMPACT_AT_CHILDREN / 4;
const DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS: usize = 250_000;
const HEAL_OBJECT_SELECT_PROB: u32 = 10; // TODO: 1024
fn heal_object_select_prob() -> u32 {
rustfs_utils::get_env_usize(ENV_HEAL_OBJECT_SELECT_PROB, DEFAULT_HEAL_OBJECT_SELECT_PROB as usize) as u32
}
/// Cached folder information for scanning
#[derive(Clone, Debug)]
@@ -1130,7 +1133,7 @@ pub async fn scan_data_folder(
// Create heal_object_select flag
let heal_object_select = if is_erasure_mode && !cache.info.skip_healing {
HEAL_OBJECT_SELECT_PROB
heal_object_select_prob()
} else {
0
};