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 GitHub
parent 5fcf166a89
commit 1d0a47460d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 0 deletions

20
Cargo.lock generated
View file

@ -2832,6 +2832,7 @@ dependencies = [
"lemmy_federate",
"lemmy_routes",
"lemmy_utils",
"mimalloc",
"reqwest-middleware",
"reqwest-tracing",
"rustls 0.23.21",
@ -2935,6 +2936,16 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
[[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 = "linked-hash-map"
version = "0.5.6"
@ -3225,6 +3236,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

@ -180,3 +180,4 @@ serde_json = { workspace = true }
rustls = { workspace = true }
tokio.workspace = true
clap = { workspace = true }
mimalloc = "0.1.43"

View file

@ -52,6 +52,7 @@ use lemmy_utils::{
settings::{structs::Settings, SETTINGS},
VERSION,
};
use mimalloc::MiMalloc;
use reqwest_middleware::ClientBuilder;
use reqwest_tracing::TracingMiddleware;
use serde_json::json;
@ -59,6 +60,9 @@ use std::{ops::Deref, time::Duration};
use tokio::signal::unix::SignalKind;
use tracing_actix_web::{DefaultRootSpanBuilder, TracingLogger};
#[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