diff --git a/Cargo.lock b/Cargo.lock index 48cce734..805c76cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,6 +154,7 @@ dependencies = [ "libc", "log", "mach2", + "mimalloc", "nvml-wrapper", "portable-pty", "predicates", @@ -211,6 +212,16 @@ dependencies = [ "rustversion", ] +[[package]] +name = "cc" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "375989decec1a0fa424442bed520fa12ede43a48475ce8c7417d2c69b32b5f6b" +dependencies = [ + "find-msvc-tools", + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.5" @@ -630,6 +641,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + [[package]] name = "float-cmp" version = "0.10.0" @@ -809,6 +826,15 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" +[[package]] +name = "libmimalloc-sys" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" +dependencies = [ + "cc", +] + [[package]] name = "libredox" version = "0.1.12" @@ -876,6 +902,15 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +[[package]] +name = "mimalloc" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mio" version = "1.1.1" @@ -1522,6 +1557,12 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77" +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + [[package]] name = "signal-hook" version = "0.3.18" diff --git a/Cargo.toml b/Cargo.toml index 65633388..9d5b1426 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ doc = false [features] # Used for general release builds. battery = ["dep:starship-battery"] +musl_alloc = ["dep:mimalloc"] nvidia = ["gpu", "dep:nvml-wrapper"] gpu = [] zfs = [] @@ -109,6 +110,9 @@ libc = "0.2.189" [target.'cfg(target_os = "linux")'.dependencies] rustix = { version = "1.1.4", features = ["fs", "param"] } +[target.'cfg(all(target_os = "linux", target_env = "musl"))'.dependencies] +mimalloc = { version = "0.1.52", optional = true } + [target.'cfg(target_os = "macos")'.dependencies] core-foundation = "0.10.1" mach2 = "0.7.0" diff --git a/src/lib.rs b/src/lib.rs index 46f713df..63724eee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,6 +63,10 @@ use crate::{app::TerminalFeatures, collection::Data}; // #[global_allocator] // static ALLOC: dhat::Alloc = dhat::Alloc; +#[cfg(all(feature = "musl_alloc", target_os = "linux", target_env = "musl"))] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + /// Try drawing. If not, clean up the terminal and return an error. fn try_drawing( terminal: &mut Terminal>, app: &mut App, painter: &mut canvas::Painter,