From b9a8f8e6c72f6f1079b458b3f6a813b7b3953a4e Mon Sep 17 00:00:00 2001 From: Jacob Taylor Date: Wed, 4 Sep 2024 08:06:18 -0700 Subject: [PATCH] automatically scale conduwuit caches by CPU-core-count --- conduwuit-example.toml | 3 ++- src/core/config/mod.rs | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 76013b85..7cf9716d 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -481,6 +481,7 @@ allow_profile_lookup_federation_requests = true ### Generic database options # Set this to any float value to multiply conduwuit's in-memory LRU caches with. +# By default, the caches scale automatically with cpu-core-count. # May be useful if you have significant memory to spare to increase performance. # # This was previously called `conduit_cache_capacity_modifier` @@ -490,7 +491,7 @@ allow_profile_lookup_federation_requests = true # 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. -# Defaults to 256.0 +# Defaults to 128.0 + (64.0 * CPU core count). #db_cache_capacity_mb = 256.0 diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 547196e4..8f857505 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -887,29 +887,29 @@ fn default_database_backups_to_keep() -> i16 { 1 } fn default_database_backend() -> String { "rocksdb".to_owned() } -fn default_db_cache_capacity_mb() -> f64 { 256.0 } +fn default_db_cache_capacity_mb() -> f64 { 128.0 + (64.0 * (crate::utils::available_parallelism() as f64)) } -fn default_pdu_cache_capacity() -> u32 { 150_000 } +fn default_pdu_cache_capacity() -> u32 { 100_000 + (10_000 * crate::utils::available_parallelism() as u32) } 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 + (10_000 * crate::utils::available_parallelism() as u32) } -fn default_shorteventid_cache_capacity() -> u32 { 500_000 } +fn default_shorteventid_cache_capacity() -> u32 { 100_000 + (50_000 * crate::utils::available_parallelism() as u32) } -fn default_eventidshort_cache_capacity() -> u32 { 100_000 } +fn default_eventidshort_cache_capacity() -> u32 { 100_000 + (25_000 * crate::utils::available_parallelism() as u32) } -fn default_shortstatekey_cache_capacity() -> u32 { 100_000 } +fn default_shortstatekey_cache_capacity() -> u32 { 100_000 + (10_000 * crate::utils::available_parallelism() as u32) } -fn default_statekeyshort_cache_capacity() -> u32 { 100_000 } +fn default_statekeyshort_cache_capacity() -> u32 { 100_000 + (10_000 * crate::utils::available_parallelism() as u32) } -fn default_server_visibility_cache_capacity() -> u32 { 100 } +fn default_server_visibility_cache_capacity() -> u32 { 500 * crate::utils::available_parallelism() as u32 } -fn default_user_visibility_cache_capacity() -> u32 { 100 } +fn default_user_visibility_cache_capacity() -> u32 { 1000 * crate::utils::available_parallelism() as u32 } -fn default_stateinfo_cache_capacity() -> u32 { 100 } +fn default_stateinfo_cache_capacity() -> u32 { 1000 * crate::utils::available_parallelism() as u32 } -fn default_roomid_spacehierarchy_cache_capacity() -> u32 { 100 } +fn default_roomid_spacehierarchy_cache_capacity() -> u32 { 1000 * crate::utils::available_parallelism() as u32 } fn default_dns_cache_entries() -> u32 { 32768 }