add granular conf items for all memory caches
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
5c30d2b2b0
commit
568136296f
4 changed files with 85 additions and 12 deletions
|
@ -51,10 +51,30 @@ pub struct Config {
|
|||
pub new_user_displayname_suffix: String,
|
||||
#[serde(default)]
|
||||
pub allow_check_for_updates: bool,
|
||||
#[serde(default = "default_conduit_cache_capacity_modifier")]
|
||||
pub conduit_cache_capacity_modifier: f64,
|
||||
|
||||
#[serde(default = "default_pdu_cache_capacity")]
|
||||
pub pdu_cache_capacity: u32,
|
||||
#[serde(default = "default_conduit_cache_capacity_modifier")]
|
||||
pub conduit_cache_capacity_modifier: f64,
|
||||
#[serde(default = "default_auth_chain_cache_capacity")]
|
||||
pub auth_chain_cache_capacity: u32,
|
||||
#[serde(default = "default_shorteventid_cache_capacity")]
|
||||
pub shorteventid_cache_capacity: u32,
|
||||
#[serde(default = "default_eventidshort_cache_capacity")]
|
||||
pub eventidshort_cache_capacity: u32,
|
||||
#[serde(default = "default_shortstatekey_cache_capacity")]
|
||||
pub shortstatekey_cache_capacity: u32,
|
||||
#[serde(default = "default_statekeyshort_cache_capacity")]
|
||||
pub statekeyshort_cache_capacity: u32,
|
||||
#[serde(default = "default_server_visibility_cache_capacity")]
|
||||
pub server_visibility_cache_capacity: u32,
|
||||
#[serde(default = "default_user_visibility_cache_capacity")]
|
||||
pub user_visibility_cache_capacity: u32,
|
||||
#[serde(default = "default_stateinfo_cache_capacity")]
|
||||
pub stateinfo_cache_capacity: u32,
|
||||
#[serde(default = "default_roomid_spacehierarchy_cache_capacity")]
|
||||
pub roomid_spacehierarchy_cache_capacity: u32,
|
||||
|
||||
#[serde(default = "default_cleanup_second_interval")]
|
||||
pub cleanup_second_interval: u32,
|
||||
#[serde(default = "default_dns_cache_entries")]
|
||||
|
@ -347,6 +367,24 @@ impl fmt::Display for Config {
|
|||
("Database cache capacity (MB)", &self.db_cache_capacity_mb.to_string()),
|
||||
("Cache capacity modifier", &self.conduit_cache_capacity_modifier.to_string()),
|
||||
("PDU cache capacity", &self.pdu_cache_capacity.to_string()),
|
||||
("Auth chain cache capacity", &self.auth_chain_cache_capacity.to_string()),
|
||||
("Short eventid cache capacity", &self.shorteventid_cache_capacity.to_string()),
|
||||
("Eventid short cache capacity", &self.eventidshort_cache_capacity.to_string()),
|
||||
("Short statekey cache capacity", &self.shortstatekey_cache_capacity.to_string()),
|
||||
("Statekey short cache capacity", &self.statekeyshort_cache_capacity.to_string()),
|
||||
(
|
||||
"Server visibility cache capacity",
|
||||
&self.server_visibility_cache_capacity.to_string(),
|
||||
),
|
||||
(
|
||||
"User visibility cache capacity",
|
||||
&self.user_visibility_cache_capacity.to_string(),
|
||||
),
|
||||
("Stateinfo cache capacity", &self.stateinfo_cache_capacity.to_string()),
|
||||
(
|
||||
"Roomid space hierarchy cache capacity",
|
||||
&self.roomid_spacehierarchy_cache_capacity.to_string(),
|
||||
),
|
||||
("Cleanup interval in seconds", &self.cleanup_second_interval.to_string()),
|
||||
("DNS cache entry limit", &self.dns_cache_entries.to_string()),
|
||||
("DNS minimum ttl", &self.dns_min_ttl.to_string()),
|
||||
|
@ -600,9 +638,27 @@ fn default_database_backend() -> String { "rocksdb".to_owned() }
|
|||
|
||||
fn default_db_cache_capacity_mb() -> f64 { 256.0 }
|
||||
|
||||
fn default_pdu_cache_capacity() -> u32 { 150_000 }
|
||||
|
||||
fn default_conduit_cache_capacity_modifier() -> f64 { 1.0 }
|
||||
|
||||
fn default_pdu_cache_capacity() -> u32 { 150_000 }
|
||||
fn default_auth_chain_cache_capacity() -> u32 { 100_000 }
|
||||
|
||||
fn default_shorteventid_cache_capacity() -> u32 { 500_000 }
|
||||
|
||||
fn default_eventidshort_cache_capacity() -> u32 { 100_000 }
|
||||
|
||||
fn default_shortstatekey_cache_capacity() -> u32 { 100_000 }
|
||||
|
||||
fn default_statekeyshort_cache_capacity() -> u32 { 100_000 }
|
||||
|
||||
fn default_server_visibility_cache_capacity() -> u32 { 100 }
|
||||
|
||||
fn default_user_visibility_cache_capacity() -> u32 { 100 }
|
||||
|
||||
fn default_stateinfo_cache_capacity() -> u32 { 100 }
|
||||
|
||||
fn default_roomid_spacehierarchy_cache_capacity() -> u32 { 100 }
|
||||
|
||||
fn default_cleanup_second_interval() -> u32 {
|
||||
1800 // every 30 minutes
|
||||
|
|
|
@ -386,18 +386,20 @@ impl KeyValueDatabase {
|
|||
.try_into()
|
||||
.expect("pdu cache capacity fits into usize"),
|
||||
)),
|
||||
auth_chain_cache: Mutex::new(LruCache::new((100_000.0 * config.conduit_cache_capacity_modifier) as usize)),
|
||||
auth_chain_cache: Mutex::new(LruCache::new(
|
||||
(f64::from(config.auth_chain_cache_capacity) * config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
shorteventid_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.shorteventid_cache_capacity) * config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
eventidshort_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.eventidshort_cache_capacity) * config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
shortstatekey_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.shortstatekey_cache_capacity) * config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
statekeyshort_cache: Mutex::new(LruCache::new(
|
||||
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.statekeyshort_cache_capacity) * config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
our_real_users_cache: RwLock::new(HashMap::new()),
|
||||
appservice_in_room_cache: RwLock::new(HashMap::new()),
|
||||
|
|
|
@ -68,6 +68,8 @@ impl Services<'_> {
|
|||
},
|
||||
auth_chain: rooms::auth_chain::Service {
|
||||
db,
|
||||
shorteventid_cache_capacity: (f64::from(config.shorteventid_cache_capacity)
|
||||
* config.conduit_cache_capacity_modifier) as usize,
|
||||
},
|
||||
directory: rooms::directory::Service {
|
||||
db,
|
||||
|
@ -101,10 +103,12 @@ impl Services<'_> {
|
|||
state_accessor: rooms::state_accessor::Service {
|
||||
db,
|
||||
server_visibility_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.server_visibility_cache_capacity) * config.conduit_cache_capacity_modifier)
|
||||
as usize,
|
||||
)),
|
||||
user_visibility_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.user_visibility_cache_capacity) * config.conduit_cache_capacity_modifier)
|
||||
as usize,
|
||||
)),
|
||||
},
|
||||
state_cache: rooms::state_cache::Service {
|
||||
|
@ -113,7 +117,7 @@ impl Services<'_> {
|
|||
state_compressor: rooms::state_compressor::Service {
|
||||
db,
|
||||
stateinfo_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.stateinfo_cache_capacity) * config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
},
|
||||
timeline: rooms::timeline::Service {
|
||||
|
@ -130,7 +134,8 @@ impl Services<'_> {
|
|||
},
|
||||
spaces: rooms::spaces::Service {
|
||||
roomid_spacehierarchy_cache: Mutex::new(LruCache::new(
|
||||
(100.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||
(f64::from(config.roomid_spacehierarchy_cache_capacity)
|
||||
* config.conduit_cache_capacity_modifier) as usize,
|
||||
)),
|
||||
},
|
||||
user: rooms::user::Service {
|
||||
|
|
|
@ -12,6 +12,7 @@ use crate::{services, Error, Result};
|
|||
|
||||
pub struct Service {
|
||||
pub db: &'static dyn Data,
|
||||
pub(crate) shorteventid_cache_capacity: usize,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
|
@ -117,6 +118,15 @@ impl Service {
|
|||
"Auth chain stats",
|
||||
);
|
||||
|
||||
if full_auth_chain.len() > self.shorteventid_cache_capacity {
|
||||
warn!(
|
||||
"Room {room_id} requires cache size of {} but it is set to {}. Increase 'shorteventid_cache_capacity' \
|
||||
in your config file.",
|
||||
full_auth_chain.len(),
|
||||
self.shorteventid_cache_capacity,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(full_auth_chain
|
||||
.into_iter()
|
||||
.filter_map(move |sid| services().rooms.short.get_eventid_from_short(sid).ok()))
|
||||
|
|
Loading…
Add table
Reference in a new issue