rename conduit_cache_capacity_modifier to cache_capacity_modifier

this prefix causes you to require setting the environment variable
to `CONDUWUIT_CONDUIT_CACHE_CAPACITY_MODIFIER`

alias this so we dont break any configs

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-07-13 16:46:13 -04:00
parent a1bfd7a018
commit bacffd6174
7 changed files with 16 additions and 12 deletions

View file

@ -421,8 +421,11 @@ allow_profile_lookup_federation_requests = true
# Set this to any float value to multiply conduwuit's in-memory LRU caches with. # Set this to any float value to multiply conduwuit's in-memory LRU caches with.
# May be useful if you have significant memory to spare to increase performance. # May be useful if you have significant memory to spare to increase performance.
#
# This was previously called `conduit_cache_capacity_modifier`
#
# Defaults to 1.0. # Defaults to 1.0.
#conduit_cache_capacity_modifier = 1.0 #cache_capacity_modifier = 1.0
# Set this to any float value in megabytes for conduwuit to tell the database engine that this much memory is available for database-related caches. # Set this to any float value in megabytes for conduwuit to tell the database engine that this much memory is available for database-related caches.
# May be useful if you have significant memory to spare to increase performance. # May be useful if you have significant memory to spare to increase performance.

View file

@ -58,8 +58,8 @@ pub struct Config {
#[serde(default = "default_pdu_cache_capacity")] #[serde(default = "default_pdu_cache_capacity")]
pub pdu_cache_capacity: u32, pub pdu_cache_capacity: u32,
#[serde(default = "default_conduit_cache_capacity_modifier")] #[serde(default = "default_cache_capacity_modifier", alias = "conduit_cache_capacity_modifier")]
pub conduit_cache_capacity_modifier: f64, pub cache_capacity_modifier: f64,
#[serde(default = "default_auth_chain_cache_capacity")] #[serde(default = "default_auth_chain_cache_capacity")]
pub auth_chain_cache_capacity: u32, pub auth_chain_cache_capacity: u32,
#[serde(default = "default_shorteventid_cache_capacity")] #[serde(default = "default_shorteventid_cache_capacity")]
@ -391,8 +391,9 @@ struct ListeningAddr {
addrs: Either<IpAddr, Vec<IpAddr>>, addrs: Either<IpAddr, Vec<IpAddr>>,
} }
const DEPRECATED_KEYS: &[&str] = &[ const DEPRECATED_KEYS: &[&str; 9] = &[
"cache_capacity", "cache_capacity",
"conduit_cache_capacity_modifier",
"max_concurrent_requests", "max_concurrent_requests",
"well_known_client", "well_known_client",
"well_known_server", "well_known_server",
@ -484,7 +485,7 @@ impl fmt::Display for Config {
); );
line("Database backups to keep", &self.database_backups_to_keep.to_string()); line("Database backups to keep", &self.database_backups_to_keep.to_string());
line("Database cache capacity (MB)", &self.db_cache_capacity_mb.to_string()); line("Database cache capacity (MB)", &self.db_cache_capacity_mb.to_string());
line("Cache capacity modifier", &self.conduit_cache_capacity_modifier.to_string()); line("Cache capacity modifier", &self.cache_capacity_modifier.to_string());
line("PDU cache capacity", &self.pdu_cache_capacity.to_string()); line("PDU cache capacity", &self.pdu_cache_capacity.to_string());
line("Auth chain cache capacity", &self.auth_chain_cache_capacity.to_string()); line("Auth chain cache capacity", &self.auth_chain_cache_capacity.to_string());
line("Short eventid cache capacity", &self.shorteventid_cache_capacity.to_string()); line("Short eventid cache capacity", &self.shorteventid_cache_capacity.to_string());
@ -847,7 +848,7 @@ fn default_db_cache_capacity_mb() -> f64 { 256.0 }
fn default_pdu_cache_capacity() -> u32 { 150_000 } fn default_pdu_cache_capacity() -> u32 { 150_000 }
fn default_conduit_cache_capacity_modifier() -> f64 { 1.0 } fn default_cache_capacity_modifier() -> f64 { 1.0 }
fn default_auth_chain_cache_capacity() -> u32 { 100_000 } fn default_auth_chain_cache_capacity() -> u32 { 100_000 }

View file

@ -310,7 +310,7 @@ fn set_table_with_shared_cache(
} }
fn cache_size(config: &Config, base_size: u32, entity_size: usize) -> usize { fn cache_size(config: &Config, base_size: u32, entity_size: usize) -> usize {
let ents = f64::from(base_size) * config.conduit_cache_capacity_modifier; let ents = f64::from(base_size) * config.cache_capacity_modifier;
#[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)] #[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)]
(ents as usize) (ents as usize)

View file

@ -16,7 +16,7 @@ impl Data {
pub(super) fn new(server: &Arc<Server>, db: &Arc<Database>) -> Self { pub(super) fn new(server: &Arc<Server>, db: &Arc<Database>) -> Self {
let config = &server.config; let config = &server.config;
let cache_size = f64::from(config.auth_chain_cache_capacity); let cache_size = f64::from(config.auth_chain_cache_capacity);
let cache_size = usize_from_f64(cache_size * config.conduit_cache_capacity_modifier).expect("valid cache size"); let cache_size = usize_from_f64(cache_size * config.cache_capacity_modifier).expect("valid cache size");
Self { Self {
shorteventid_authchain: db["shorteventid_authchain"].clone(), shorteventid_authchain: db["shorteventid_authchain"].clone(),
auth_chain_cache: Mutex::new(LruCache::new(cache_size)), auth_chain_cache: Mutex::new(LruCache::new(cache_size)),

View file

@ -161,7 +161,7 @@ impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> { fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
let config = &args.server.config; let config = &args.server.config;
let cache_size = f64::from(config.roomid_spacehierarchy_cache_capacity); let cache_size = f64::from(config.roomid_spacehierarchy_cache_capacity);
let cache_size = cache_size * config.conduit_cache_capacity_modifier; let cache_size = cache_size * config.cache_capacity_modifier;
Ok(Arc::new(Self { Ok(Arc::new(Self {
roomid_spacehierarchy_cache: Mutex::new(LruCache::new(usize_from_f64(cache_size)?)), roomid_spacehierarchy_cache: Mutex::new(LruCache::new(usize_from_f64(cache_size)?)),
})) }))

View file

@ -45,9 +45,9 @@ impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> { fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
let config = &args.server.config; let config = &args.server.config;
let server_visibility_cache_capacity = let server_visibility_cache_capacity =
f64::from(config.server_visibility_cache_capacity) * config.conduit_cache_capacity_modifier; f64::from(config.server_visibility_cache_capacity) * config.cache_capacity_modifier;
let user_visibility_cache_capacity = let user_visibility_cache_capacity =
f64::from(config.user_visibility_cache_capacity) * config.conduit_cache_capacity_modifier; f64::from(config.user_visibility_cache_capacity) * config.cache_capacity_modifier;
Ok(Arc::new(Self { Ok(Arc::new(Self {
db: Data::new(args.db), db: Data::new(args.db),

View file

@ -55,7 +55,7 @@ pub struct Service {
impl crate::Service for Service { impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> { fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
let config = &args.server.config; let config = &args.server.config;
let cache_capacity = f64::from(config.stateinfo_cache_capacity) * config.conduit_cache_capacity_modifier; let cache_capacity = f64::from(config.stateinfo_cache_capacity) * config.cache_capacity_modifier;
Ok(Arc::new(Self { Ok(Arc::new(Self {
db: Data::new(args.db), db: Data::new(args.db),
stateinfo_cache: StdMutex::new(LruCache::new(usize_from_f64(cache_capacity)?)), stateinfo_cache: StdMutex::new(LruCache::new(usize_from_f64(cache_capacity)?)),