perf(rust): make mimalloc opt-in behind a cargo feature

pydantic-core shipped mimalloc from Jun 2022 to Aug 2023 and removed it
(pydantic-core#900) after: a TLS-linkage fix (pydantic-core#363), manylinux
cross-compile breakage (pydantic-core#893), 1GiB of reserved virtual memory
at import breaking RLIMIT_AS-limited processes (pydantic#7167), and
container memory-footprint complaints (pydantic#6620). litellm wheels land
in exactly those memory-limited container deployments, so the allocator
override must be an explicit build-time choice, not a default imposed on
every wheel. The feature stays available for self-built deployments that
want it; wheels build without it.
This commit is contained in:
Yujong Lee 2026-09-03 10:15:03 -07:00
parent 17bcc04800
commit b7453a25d7
2 changed files with 3 additions and 1 deletions

View file

@ -13,11 +13,12 @@ crate-type = ["cdylib"]
default = ["abi3"]
abi3 = ["pyo3/abi3-py310"]
extension-module = ["pyo3/extension-module"]
mimalloc = ["dep:mimalloc"]
panic-test = []
[dependencies]
futures-util.workspace = true
mimalloc.workspace = true
mimalloc = { workspace = true, optional = true }
tracing.workspace = true
tracing-subscriber.workspace = true
litellm-core = { workspace = true, features = ["bedrock-auth"] }

View file

@ -11,6 +11,7 @@ use pyo3::prelude::*;
use pyo3::types::PyAny;
use serde_json::Value;
#[cfg(feature = "mimalloc")]
#[global_allocator]
static ALLOCATOR: mimalloc::MiMalloc = mimalloc::MiMalloc;