Use mimalloc as memory allocator (#5378)

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
Nutomic 2025-02-04 00:14:12 +00:00 committed by Felix Ableitner
parent cee261d6c8
commit cee6975d59
3 changed files with 25 additions and 0 deletions

20
Cargo.lock generated
View file

@ -3157,6 +3157,7 @@ dependencies = [
"lemmy_federate",
"lemmy_routes",
"lemmy_utils",
"mimalloc",
"opentelemetry 0.19.0",
"opentelemetry-otlp 0.12.0",
"pict-rs",
@ -3266,6 +3267,16 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libmimalloc-sys"
version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "line-wrap"
version = "0.2.0"
@ -3534,6 +3545,15 @@ dependencies = [
"quote",
]
[[package]]
name = "mimalloc"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633"
dependencies = [
"libmimalloc-sys",
]
[[package]]
name = "mime"
version = "0.3.17"

View file

@ -211,6 +211,7 @@ chrono = { workspace = true }
prometheus = { version = "0.13.4", features = ["process"] }
serial_test = { workspace = true }
clap = { workspace = true }
mimalloc = "0.1.43"
actix-web-prom = "0.8.0"
[dev-dependencies]

View file

@ -52,6 +52,7 @@ use lemmy_utils::{
};
use prometheus::default_registry;
use prometheus_metrics::serve_prometheus;
use mimalloc::MiMalloc;
use reqwest_middleware::ClientBuilder;
use reqwest_tracing::TracingMiddleware;
use serde_json::json;
@ -64,6 +65,9 @@ use tracing_log::LogTracer;
use tracing_subscriber::{filter::Targets, layer::SubscriberExt, Layer, Registry};
use url::Url;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
/// Timeout for HTTP requests while sending activities. A longer timeout provides better
/// compatibility with other ActivityPub software that might allocate more time for synchronous
/// processing of incoming activities. This timeout should be slightly longer than the time we