diff options
Diffstat (limited to 'crates/arti/src')
| -rw-r--r-- | crates/arti/src/arti-example-config.toml | 21 | ||||
| -rw-r--r-- | crates/arti/src/cfg.rs | 48 |
2 files changed, 33 insertions, 36 deletions
diff --git a/crates/arti/src/arti-example-config.toml b/crates/arti/src/arti-example-config.toml index 4d80738c7..1ce4770ed 100644 --- a/crates/arti/src/arti-example-config.toml +++ b/crates/arti/src/arti-example-config.toml @@ -473,15 +473,26 @@ #max_files = 16384 # Are we limiting memory use and if so to how much? -# The default is unlimited. # -# Maximum memory use, after which reclamation starts: +# Maximum memory use, after which reclamation starts. +# +# The default is "auto", which uses a value derived from the total system +# memory. It should not be assumed that the value used for "auto" will remain +# stable across different versions of arti. The value used for "auto" may also +# take into account other OS-specific features, such as cgroups on Linux. +# +# If `system.memory.low_water` is given as an explicit value, +# `system.memory.max` must also be given as an explicit value. +# # memory.max = "8 GiB" -# (If anything is specified in `[system.memory]`, this value is mandatory.) # -# When reclaiming memory, we stop when we reach this amount: +# When reclaiming memory, we stop when we reach this amount. +# +# The default is "auto", which uses 3/4 of `system.memory.max`. It should not be +# assumed that the value used for "auto" will remain stable across different +# versions of arti. +# # memory.low_water = "6 GiB" -# (The default is 3/4 of `system.memory.max`.) ##### ONION SERVICES # diff --git a/crates/arti/src/cfg.rs b/crates/arti/src/cfg.rs index 5454e7532..b67a4a814 100644 --- a/crates/arti/src/cfg.rs +++ b/crates/arti/src/cfg.rs @@ -1261,37 +1261,23 @@ example config file {which:?}, uncommented={uncommented:?} let result = file.resolve_return_results::<(TorClientConfig, ArtiConfig)>(); - cfg_if::cfg_if! { - if #[cfg(feature = "memquota")] { - let result = result.unwrap(); - - // Test that the example config doesn't have any unrecognised keys - assert_eq!(result.unrecognized, []); - assert_eq!(result.deprecated, []); - - let inner: &tor_memquota::testing::ConfigInner = - result.value.0.system_memory().inner().unwrap(); - - // Test that the example low_water is the default - // value for the example max. - let defaulted_low = tor_memquota::Config::builder() - .max(*inner.max) - .build() - .unwrap(); - let inner_defaulted_low = defaulted_low.inner().unwrap(); - assert_eq!(inner, inner_defaulted_low); - } else if #[cfg(arti_features_precise)] { - // Test that requesting memory quota tracking generates a config error - // if support is compiled out. - let m = result.unwrap_err().report().to_string(); - assert!(m.contains("cargo feature `memquota` disabled"), "{m:?}"); - } else { - // The `tor-memquota/memquota` feature is enabled by default in tor-memquota, - // but the corresponding `memquota` feature is but not enabled here in `arti`. - // so cargo --workspace enables it in a way we can't tell. See arti/build.rs. - println!("not testing memquota config, cannot figure out if it's enabled"); - } - } + let result = result.unwrap(); + + // Test that the example config doesn't have any unrecognised keys + assert_eq!(result.unrecognized, []); + assert_eq!(result.deprecated, []); + + let inner: &tor_memquota::testing::ConfigInner = + result.value.0.system_memory().inner().unwrap(); + + // Test that the example low_water is the default + // value for the example max. + let defaulted_low = tor_memquota::Config::builder() + .max(*inner.max) + .build() + .unwrap(); + let inner_defaulted_low = defaulted_low.inner().unwrap(); + assert_eq!(inner, inner_defaulted_low); } #[test] |
