Unverified Commit 0b7a18ce authored by Graham King's avatar Graham King Committed by GitHub
Browse files

chore: Remove dependency memory -> config (#7993)


Signed-off-by: default avatarGraham King <grahamk@nvidia.com>
parent a210efa6
...@@ -1996,7 +1996,6 @@ version = "1.0.0" ...@@ -1996,7 +1996,6 @@ version = "1.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cudarc", "cudarc",
"dynamo-config",
"libc", "libc",
"nix 0.30.1", "nix 0.30.1",
"nixl-sys", "nixl-sys",
......
...@@ -1647,7 +1647,6 @@ version = "1.0.0" ...@@ -1647,7 +1647,6 @@ version = "1.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cudarc", "cudarc",
"dynamo-config",
"libc", "libc",
"nix 0.30.1", "nix 0.30.1",
"nixl-sys", "nixl-sys",
......
...@@ -1662,7 +1662,6 @@ version = "1.0.0" ...@@ -1662,7 +1662,6 @@ version = "1.0.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cudarc", "cudarc",
"dynamo-config",
"libc", "libc",
"nix 0.30.1", "nix 0.30.1",
"nixl-sys", "nixl-sys",
......
...@@ -23,8 +23,6 @@ testing-nixl = [] ...@@ -23,8 +23,6 @@ testing-nixl = []
testing-all = ["testing-cuda", "testing-nixl"] testing-all = ["testing-cuda", "testing-nixl"]
[dependencies] [dependencies]
dynamo-config = { workspace = true }
anyhow = { workspace = true } anyhow = { workspace = true }
cudarc = { workspace = true } cudarc = { workspace = true }
nixl-sys = { version = "=0.10.1" } nixl-sys = { version = "=0.10.1" }
......
...@@ -301,3 +301,43 @@ impl MemoryRegion { ...@@ -301,3 +301,43 @@ impl MemoryRegion {
} }
} }
} }
/// Check if an environment variable is truthy
pub fn env_is_truthy(env: &str) -> bool {
match std::env::var(env) {
Ok(val) => matches!(val.to_lowercase().as_str(), "1" | "true" | "on" | "yes"),
Err(_) => false,
}
}
/// Parse a string as a boolean value, returning an error if invalid.
/// Do not use this unless you really need to support vague values. Prefer only allowing a specific
/// value.
///
/// This function strictly validates that the input is a valid boolean representation.
///
/// # Arguments
/// * `val` - The string value to parse
///
/// # Returns
/// * `Ok(true)` - For truthy values: "1", "true", "on", "yes" (case-insensitive)
/// * `Ok(false)` - For falsey values: "0", "false", "off", "no" (case-insensitive)
/// * `Err(_)` - For any other value
///
/// # Example
/// ```ignore
/// assert_eq!(parse_bool("true")?, true);
/// assert_eq!(parse_bool("0")?, false);
/// assert!(parse_bool("maybe").is_err());
/// ```
pub fn parse_bool(val: &str) -> anyhow::Result<bool> {
if matches!(val.to_lowercase().as_str(), "1" | "true" | "on" | "yes") {
Ok(true)
} else if matches!(val.to_lowercase().as_str(), "0" | "false" | "off" | "no") {
Ok(false)
} else {
anyhow::bail!(
"Invalid boolean value: '{val}'. Expected one of: true/false, 1/0, on/off, yes/no",
)
}
}
...@@ -10,8 +10,6 @@ use anyhow::{Result, bail}; ...@@ -10,8 +10,6 @@ use anyhow::{Result, bail};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use dynamo_config::parse_bool;
/// Configuration for NIXL backends. /// Configuration for NIXL backends.
/// ///
/// Supports extracting backend configurations from environment variables: /// Supports extracting backend configurations from environment variables:
...@@ -82,7 +80,7 @@ impl NixlBackendConfig { ...@@ -82,7 +80,7 @@ impl NixlBackendConfig {
// Simple backend enablement (e.g., DYN_KVBM_NIXL_BACKEND_UCX=true) // Simple backend enablement (e.g., DYN_KVBM_NIXL_BACKEND_UCX=true)
let backend_name = remainder.to_uppercase(); let backend_name = remainder.to_uppercase();
match parse_bool(&value) { match crate::parse_bool(&value) {
Ok(true) => { Ok(true) => {
backends.insert(backend_name, HashMap::new()); backends.insert(backend_name, HashMap::new());
} }
......
...@@ -45,7 +45,7 @@ static NUMA_NODE_CACHE: OnceLock<Mutex<HashMap<String, Option<NumaNode>>>> = Onc ...@@ -45,7 +45,7 @@ static NUMA_NODE_CACHE: OnceLock<Mutex<HashMap<String, Option<NumaNode>>>> = Onc
/// NUMA-aware allocation is enabled by default. Set `DYN_MEMORY_DISABLE_NUMA=1` /// NUMA-aware allocation is enabled by default. Set `DYN_MEMORY_DISABLE_NUMA=1`
/// (or any truthy value) to disable it. /// (or any truthy value) to disable it.
pub fn is_numa_disabled() -> bool { pub fn is_numa_disabled() -> bool {
dynamo_config::env_is_truthy("DYN_MEMORY_DISABLE_NUMA") crate::env_is_truthy("DYN_MEMORY_DISABLE_NUMA")
} }
/// Represents a NUMA node identifier. /// Represents a NUMA node identifier.
......
...@@ -15,7 +15,7 @@ use std::sync::Arc; ...@@ -15,7 +15,7 @@ use std::sync::Arc;
/// (e.g. Grace Hopper / Blackwell with NVLink-C2C). Must be accessed only after /// (e.g. Grace Hopper / Blackwell with NVLink-C2C). Must be accessed only after
/// a CUDA context has been bound to the current thread. /// a CUDA context has been bound to the current thread.
static USE_WRITE_COMBINED: std::sync::LazyLock<bool> = std::sync::LazyLock::new(|| { static USE_WRITE_COMBINED: std::sync::LazyLock<bool> = std::sync::LazyLock::new(|| {
if dynamo_config::env_is_truthy("DYN_KVBM_DISABLE_WRITE_COMBINED") { if crate::env_is_truthy("DYN_KVBM_DISABLE_WRITE_COMBINED") {
tracing::debug!("DYN_KVBM_DISABLE_WRITE_COMBINED set; write-combined disabled"); tracing::debug!("DYN_KVBM_DISABLE_WRITE_COMBINED set; write-combined disabled");
return false; return false;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment