Skip to content

Commit

Permalink
Add mimalloc support to iggy-server and make it default allocator for…
Browse files Browse the repository at this point in the history
… musl env (#1406)

This commit introduces support for the mimalloc allocator as an optional
feature in the server package. The Cargo.toml and Cargo.lock files have
been updated to include mimalloc and its dependencies. Additionally, the
server version is incremented to 0.4.93.

This closes #1347.
  • Loading branch information
hubcio authored Dec 30, 2024
1 parent d40d9cc commit 526ca77
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
43 changes: 21 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "server"
version = "0.4.92"
version = "0.4.93"
edition = "2021"
build = "src/build.rs"

[features]
default = []
jemalloc = ["dep:tikv-jemallocator"]
mimalloc = ["dep:mimalloc"]
tokio-console = ["dep:console-subscriber", "tokio/tracing"]

[dependencies]
Expand Down Expand Up @@ -90,7 +90,10 @@ xxhash-rust = { version = "0.8.12", features = ["xxh32"] }
zip = "2.2.0"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = { version = "0.6", optional = true }
mimalloc = { version = "0.1", optional = true }

[target.'cfg(target_env = "musl")'.dependencies]
mimalloc = { version = "0.1", features = ["override"] }

[build-dependencies]
figment = { version = "0.10.18", features = ["json", "toml", "env"] }
Expand Down
11 changes: 4 additions & 7 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[cfg(all(target_env = "msvc", feature = "jemalloc"))]
compile_error!("'jemalloc' feature cannot be used when MSVC is being used");
#[cfg(any(feature = "mimalloc", target_env = "musl"))]
use mimalloc::MiMalloc;

#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
use tikv_jemallocator::Jemalloc;

#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
#[cfg(any(feature = "mimalloc", target_env = "musl"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
static GLOBAL: MiMalloc = MiMalloc;

pub mod archiver;
pub mod args;
Expand Down

0 comments on commit 526ca77

Please sign in to comment.