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,
|
pub new_user_displayname_suffix: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub allow_check_for_updates: bool,
|
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")]
|
#[serde(default = "default_pdu_cache_capacity")]
|
||||||
pub pdu_cache_capacity: u32,
|
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")]
|
#[serde(default = "default_cleanup_second_interval")]
|
||||||
pub cleanup_second_interval: u32,
|
pub cleanup_second_interval: u32,
|
||||||
#[serde(default = "default_dns_cache_entries")]
|
#[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()),
|
("Database cache capacity (MB)", &self.db_cache_capacity_mb.to_string()),
|
||||||
("Cache capacity modifier", &self.conduit_cache_capacity_modifier.to_string()),
|
("Cache capacity modifier", &self.conduit_cache_capacity_modifier.to_string()),
|
||||||
("PDU cache capacity", &self.pdu_cache_capacity.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()),
|
("Cleanup interval in seconds", &self.cleanup_second_interval.to_string()),
|
||||||
("DNS cache entry limit", &self.dns_cache_entries.to_string()),
|
("DNS cache entry limit", &self.dns_cache_entries.to_string()),
|
||||||
("DNS minimum ttl", &self.dns_min_ttl.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_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_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 {
|
fn default_cleanup_second_interval() -> u32 {
|
||||||
1800 // every 30 minutes
|
1800 // every 30 minutes
|
||||||
|
|
|
@ -386,18 +386,20 @@ impl KeyValueDatabase {
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("pdu cache capacity fits into usize"),
|
.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(
|
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(
|
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(
|
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(
|
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()),
|
our_real_users_cache: RwLock::new(HashMap::new()),
|
||||||
appservice_in_room_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 {
|
auth_chain: rooms::auth_chain::Service {
|
||||||
db,
|
db,
|
||||||
|
shorteventid_cache_capacity: (f64::from(config.shorteventid_cache_capacity)
|
||||||
|
* config.conduit_cache_capacity_modifier) as usize,
|
||||||
},
|
},
|
||||||
directory: rooms::directory::Service {
|
directory: rooms::directory::Service {
|
||||||
db,
|
db,
|
||||||
|
@ -101,10 +103,12 @@ impl Services<'_> {
|
||||||
state_accessor: rooms::state_accessor::Service {
|
state_accessor: rooms::state_accessor::Service {
|
||||||
db,
|
db,
|
||||||
server_visibility_cache: StdMutex::new(LruCache::new(
|
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(
|
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 {
|
state_cache: rooms::state_cache::Service {
|
||||||
|
@ -113,7 +117,7 @@ impl Services<'_> {
|
||||||
state_compressor: rooms::state_compressor::Service {
|
state_compressor: rooms::state_compressor::Service {
|
||||||
db,
|
db,
|
||||||
stateinfo_cache: StdMutex::new(LruCache::new(
|
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 {
|
timeline: rooms::timeline::Service {
|
||||||
|
@ -130,7 +134,8 @@ impl Services<'_> {
|
||||||
},
|
},
|
||||||
spaces: rooms::spaces::Service {
|
spaces: rooms::spaces::Service {
|
||||||
roomid_spacehierarchy_cache: Mutex::new(LruCache::new(
|
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 {
|
user: rooms::user::Service {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::{services, Error, Result};
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
pub db: &'static dyn Data,
|
pub db: &'static dyn Data,
|
||||||
|
pub(crate) shorteventid_cache_capacity: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
|
@ -117,6 +118,15 @@ impl Service {
|
||||||
"Auth chain stats",
|
"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
|
Ok(full_auth_chain
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(move |sid| services().rooms.short.get_eventid_from_short(sid).ok()))
|
.filter_map(move |sid| services().rooms.short.get_eventid_from_short(sid).ok()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue