From 5ad514d59cfa4d207ece739ed502e4e1e00d1606 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 29 Sep 2024 12:10:59 -0600 Subject: [PATCH] Use mimalloc when targeting musl Also removes the armv7 linux build. If you used it, let me know! --- .github/workflows/build.yaml | 5 ----- Cargo.lock | 20 ++++++++++++++++++++ nodtool/Cargo.toml | 3 +++ nodtool/src/main.rs | 6 ++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8ade63c..47e250c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -106,11 +106,6 @@ jobs: name: linux-aarch64 build: zigbuild features: nightly - - platform: ubuntu-latest - target: armv7-unknown-linux-musleabi - name: linux-armv7l - build: zigbuild - features: default - platform: windows-latest target: i686-pc-windows-msvc name: windows-x86 diff --git a/Cargo.lock b/Cargo.lock index 7b41ef8..e1b6f81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -376,6 +376,16 @@ dependencies = [ "pkg-config", ] +[[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 = "log" version = "0.4.22" @@ -417,6 +427,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "mimalloc" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -463,6 +482,7 @@ dependencies = [ "itertools", "log", "md-5", + "mimalloc", "nod", "quick-xml", "serde", diff --git a/nodtool/Cargo.toml b/nodtool/Cargo.toml index ff83d4f..367723f 100644 --- a/nodtool/Cargo.toml +++ b/nodtool/Cargo.toml @@ -43,6 +43,9 @@ xxhash-rust = { version = "0.8", features = ["xxh64"] } zerocopy = { version = "0.7", features = ["alloc", "derive"] } zstd = "0.13" +[target.'cfg(target_env = "musl")'.dependencies] +mimalloc = "0.1" + [build-dependencies] hex = { version = "0.4", features = ["serde"] } quick-xml = { version = "0.36", features = ["serialize"] } diff --git a/nodtool/src/main.rs b/nodtool/src/main.rs index f57b377..90ee79f 100644 --- a/nodtool/src/main.rs +++ b/nodtool/src/main.rs @@ -1,5 +1,11 @@ mod argp_version; +// musl's allocator is very slow, so use mimalloc when targeting musl. +// Otherwise, use the system allocator to avoid extra code size. +#[cfg(target_env = "musl")] +#[global_allocator] +static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; + use std::{env, error::Error, ffi::OsStr, fmt, path::PathBuf, str::FromStr}; use argp::{FromArgValue, FromArgs};