Skip to content

Commit

Permalink
Put the cli argument behind a feature flag
Browse files Browse the repository at this point in the history
Signed-off-by: Monthon Klongklaew <[email protected]>
  • Loading branch information
monthonk committed Sep 26, 2024
1 parent 80837d2 commit 5db1220
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions mountpoint-s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
20 changes: 12 additions & 8 deletions mountpoint-s3/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5db1220

Please sign in to comment.