ws: add mimalloc feature to make it easier to disable it

This commit is contained in:
Joakim Frostegård 2024-01-07 10:41:11 +01:00
parent 3042539101
commit 6e7d36cffc
3 changed files with 8 additions and 5 deletions

View file

@ -6,7 +6,6 @@
interval to clean up data. should more or less fix prometheus memory leak interval to clean up data. should more or less fix prometheus memory leak
* ws * ws
* mimalloc feature, same for http
* try replacing race with futures::future::select * try replacing race with futures::future::select
* bug report for glommio regarding memory leak * bug report for glommio regarding memory leak

View file

@ -18,9 +18,12 @@ name = "aquatic_ws"
name = "aquatic_ws" name = "aquatic_ws"
[features] [features]
default = ["prometheus"] default = ["prometheus", "mimalloc"]
prometheus = ["metrics", "metrics-exporter-prometheus"] prometheus = ["metrics", "metrics-exporter-prometheus"]
metrics = ["dep:metrics", "metrics-util"] metrics = ["dep:metrics", "metrics-util"]
# Use mimalloc allocator for much better performance. Requires cmake and a
# C/C++ compiler
mimalloc = ["dep:mimalloc"]
[dependencies] [dependencies]
aquatic_common = { workspace = true, features = ["rustls", "glommio"] } aquatic_common = { workspace = true, features = ["rustls", "glommio"] }
@ -43,7 +46,7 @@ log = "0.4"
metrics = { version = "0.22", optional = true } metrics = { version = "0.22", optional = true }
metrics-util = { version = "0.16", optional = true } metrics-util = { version = "0.16", optional = true }
metrics-exporter-prometheus = { version = "0.13", optional = true, default-features = false, features = ["http-listener"] } metrics-exporter-prometheus = { version = "0.13", optional = true, default-features = false, features = ["http-listener"] }
mimalloc = { version = "0.1", default-features = false } mimalloc = { version = "0.1", default-features = false, optional = true }
privdrop = "0.5" privdrop = "0.5"
rand = { version = "0.8", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
rustls = "0.22" rustls = "0.22"

View file

@ -1,8 +1,9 @@
use aquatic_common::cli::run_app_with_cli_and_config; use aquatic_common::cli::run_app_with_cli_and_config;
use aquatic_ws::config::Config; use aquatic_ws::config::Config;
// #[global_allocator] #[cfg(feature = "mimalloc")]
// static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn main() { fn main() {
run_app_with_cli_and_config::<Config>( run_app_with_cli_and_config::<Config>(