Make mimalloc optional for udp and http

This commit is contained in:
Joakim Frostegård 2024-05-03 22:38:25 +02:00
parent f061c47ef8
commit 7795a1a532
5 changed files with 21 additions and 5 deletions

View file

@ -18,9 +18,13 @@ name = "aquatic_http"
name = "aquatic_http"
[features]
default = ["prometheus"]
default = ["prometheus", "mimalloc"]
prometheus = ["aquatic_common/prometheus", "metrics", "dep:metrics-util"]
metrics = ["dep:metrics"]
# Use mimalloc allocator for much better performance.
#
# Requires cmake and a C compiler
mimalloc = ["dep:mimalloc"]
[dependencies]
aquatic_common = { workspace = true, features = ["rustls"] }
@ -40,7 +44,6 @@ httparse = "1"
itoa = "1"
libc = "0.2"
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
memchr = "2"
privdrop = "0.5"
once_cell = "1"
@ -56,6 +59,9 @@ thiserror = "1"
metrics = { version = "0.22", optional = true }
metrics-util = { version = "0.16", optional = true }
# mimalloc feature
mimalloc = { version = "0.1", default-features = false, optional = true }
[dev-dependencies]
quickcheck = "1"
quickcheck_macros = "1"

View file

@ -1,6 +1,7 @@
use aquatic_common::cli::run_app_with_cli_and_config;
use aquatic_http::config::Config;
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

View file

@ -18,13 +18,17 @@ name = "aquatic_udp"
name = "aquatic_udp"
[features]
default = ["prometheus"]
default = ["prometheus", "mimalloc"]
# Export prometheus metrics
prometheus = ["metrics", "aquatic_common/prometheus"]
# Experimental io_uring support (Linux 6.0 or later required)
io-uring = ["dep:io-uring"]
# Experimental CPU pinning support
cpu-pinning = ["aquatic_common/cpu-pinning"]
# Use mimalloc allocator for much better performance.
#
# Requires cmake and a C compiler
mimalloc = ["dep:mimalloc"]
[dependencies]
aquatic_common.workspace = true
@ -45,7 +49,6 @@ hdrhistogram = "7"
hex = "0.4"
libc = "0.2"
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
mio = { version = "0.8", features = ["net", "os-poll"] }
num-format = "0.4"
parking_lot = "0.12"
@ -63,6 +66,9 @@ metrics = { version = "0.22", optional = true }
# io-uring feature
io-uring = { version = "0.6", optional = true }
# mimalloc feature
mimalloc = { version = "0.1", default-features = false, optional = true }
[dev-dependencies]
tempfile = "3"
quickcheck = "1"

View file

@ -1,3 +1,4 @@
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

View file

@ -44,7 +44,6 @@ hashbrown = { version = "0.14", features = ["serde"] }
httparse = "1"
indexmap = "2"
log = "0.4"
mimalloc = { version = "0.1", default-features = false, optional = true }
privdrop = "0.5"
rand = { version = "0.8", features = ["small_rng"] }
rustls = "0.23"
@ -60,6 +59,9 @@ tungstenite = "0.21"
metrics = { version = "0.22", optional = true }
metrics-util = { version = "0.16", optional = true }
# mimalloc feature
mimalloc = { version = "0.1", default-features = false, optional = true }
[dev-dependencies]
quickcheck = "1"
quickcheck_macros = "1"