mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
make all caches individually configurable
Also: * Removes the `cache_capacity_modifier` option * Renames the `pdu_cache_capacity` option to `cache.pdu`
This commit is contained in:
parent
9fab7538a0
commit
1148c6004f
4 changed files with 65 additions and 110 deletions
|
|
@ -46,11 +46,8 @@ pub(crate) struct Config {
|
|||
pub(crate) database: DatabaseConfig,
|
||||
#[serde(default)]
|
||||
pub(crate) federation: FederationConfig,
|
||||
|
||||
#[serde(default = "default_cache_capacity_modifier")]
|
||||
pub(crate) cache_capacity_modifier: f64,
|
||||
#[serde(default = "default_pdu_cache_capacity")]
|
||||
pub(crate) pdu_cache_capacity: usize,
|
||||
#[serde(default)]
|
||||
pub(crate) cache: CacheConfig,
|
||||
#[serde(default = "default_cleanup_second_interval")]
|
||||
pub(crate) cleanup_second_interval: u32,
|
||||
#[serde(default = "default_max_request_size")]
|
||||
|
|
@ -77,6 +74,38 @@ pub(crate) struct Config {
|
|||
pub(crate) emergency_password: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields, default)]
|
||||
pub(crate) struct CacheConfig {
|
||||
pub(crate) pdu: usize,
|
||||
pub(crate) auth_chain: usize,
|
||||
pub(crate) short_eventid: usize,
|
||||
pub(crate) eventid_short: usize,
|
||||
pub(crate) statekey_short: usize,
|
||||
pub(crate) short_statekey: usize,
|
||||
pub(crate) server_visibility: usize,
|
||||
pub(crate) user_visibility: usize,
|
||||
pub(crate) state_info: usize,
|
||||
pub(crate) roomid_spacechunk: usize,
|
||||
}
|
||||
|
||||
impl Default for CacheConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pdu: 150_000,
|
||||
auth_chain: 100_000,
|
||||
short_eventid: 100_000,
|
||||
eventid_short: 100_000,
|
||||
statekey_short: 100_000,
|
||||
short_statekey: 100_000,
|
||||
server_visibility: 100,
|
||||
user_visibility: 100,
|
||||
state_info: 100,
|
||||
roomid_spacechunk: 200,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct ServerDiscovery {
|
||||
|
|
@ -427,19 +456,11 @@ fn default_db_cache_capacity_mb() -> f64 {
|
|||
300.0
|
||||
}
|
||||
|
||||
fn default_cache_capacity_modifier() -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[cfg(feature = "rocksdb")]
|
||||
fn default_rocksdb_max_open_files() -> i32 {
|
||||
1000
|
||||
}
|
||||
|
||||
fn default_pdu_cache_capacity() -> usize {
|
||||
150_000
|
||||
}
|
||||
|
||||
fn default_cleanup_second_interval() -> u32 {
|
||||
// every minute
|
||||
60
|
||||
|
|
|
|||
|
|
@ -67,14 +67,7 @@ impl Services {
|
|||
alias: rooms::alias::Service::new(db),
|
||||
auth_chain: rooms::auth_chain::Service::new(
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
config.cache.auth_chain,
|
||||
),
|
||||
directory: db,
|
||||
edus: rooms::edus::Service {
|
||||
|
|
@ -91,89 +84,30 @@ impl Services {
|
|||
search: db,
|
||||
short: rooms::short::Service::new(
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100_000.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
config.cache.short_eventid,
|
||||
config.cache.eventid_short,
|
||||
config.cache.statekey_short,
|
||||
config.cache.short_statekey,
|
||||
),
|
||||
state: rooms::state::Service {
|
||||
db,
|
||||
},
|
||||
state_accessor: rooms::state_accessor::Service::new(
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
config.cache.server_visibility,
|
||||
config.cache.user_visibility,
|
||||
),
|
||||
state_cache: rooms::state_cache::Service::new(db),
|
||||
state_compressor: rooms::state_compressor::Service::new(
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(100.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
),
|
||||
timeline: rooms::timeline::Service::new(
|
||||
db,
|
||||
config.pdu_cache_capacity,
|
||||
config.cache.state_info,
|
||||
),
|
||||
timeline: rooms::timeline::Service::new(db, config.cache.pdu),
|
||||
threads: rooms::threads::Service {
|
||||
db,
|
||||
},
|
||||
spaces: rooms::spaces::Service::new(
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
{
|
||||
(200.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
config.cache.roomid_spacechunk,
|
||||
),
|
||||
user: db,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue