From 5db12207dca369b98acdefc0f7ed33bd418b7794 Mon Sep 17 00:00:00 2001 From: Monthon Klongklaew Date: Thu, 26 Sep 2024 09:10:55 +0000 Subject: [PATCH] Put the cli argument behind a feature flag Signed-off-by: Monthon Klongklaew --- mountpoint-s3/Cargo.toml | 1 + mountpoint-s3/src/cli.rs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mountpoint-s3/Cargo.toml b/mountpoint-s3/Cargo.toml index 93868ad77..bc68fabce 100644 --- a/mountpoint-s3/Cargo.toml +++ b/mountpoint-s3/Cargo.toml @@ -82,6 +82,7 @@ built = { version = "0.7.1", features = ["git2"] } [features] # Unreleased feature flags event_log = [] +mem_limiter = [] # Features for choosing tests fips_tests = [] fuse_tests = [] diff --git a/mountpoint-s3/src/cli.rs b/mountpoint-s3/src/cli.rs index 5cabc2871..1988d81c6 100644 --- a/mountpoint-s3/src/cli.rs +++ b/mountpoint-s3/src/cli.rs @@ -157,6 +157,8 @@ pub struct CliArgs { )] pub max_threads: u64, + // This config is still unstable + #[cfg(feature = "mem_limiter")] #[clap( long, help = "Maximum memory usage target [default: 95% of total system memory with a minimum of 512 MiB]", @@ -743,14 +745,16 @@ where filesystem_config.allow_overwrite = args.allow_overwrite; filesystem_config.s3_personality = s3_personality; filesystem_config.server_side_encryption = ServerSideEncryption::new(args.sse, args.sse_kms_key_id); - filesystem_config.mem_limit = if let Some(max_mem_target) = args.max_memory_target { - max_mem_target * 1024 * 1024 - } else { - const MINIMUM_MEM_LIMIT: u64 = 512 * 1024 * 1024; - let sys = System::new_with_specifics(RefreshKind::everything()); - let default_mem_target = (sys.total_memory() as f64 * 0.95) as u64; - default_mem_target.max(MINIMUM_MEM_LIMIT) - }; + + const MINIMUM_MEM_LIMIT: u64 = 512 * 1024 * 1024; + let sys = System::new_with_specifics(RefreshKind::everything()); + let default_mem_target = (sys.total_memory() as f64 * 0.95) as u64; + filesystem_config.mem_limit = default_mem_target.max(MINIMUM_MEM_LIMIT); + + #[cfg(feature = "mem_limiter")] + if let Some(max_mem_target) = args.max_memory_target { + filesystem_config.mem_limit = max_mem_target * 1024 * 1024; + } // Written in this awkward way to force us to update it if we add new checksum types filesystem_config.use_upload_checksums = match args.upload_checksums {