Use mimalloc when targeting musl

Also removes the armv7 linux build.
If you used it, let me know!
This commit is contained in:
Luke Street 2024-09-29 12:10:59 -06:00
parent 312dd6f080
commit 5ad514d59c
4 changed files with 29 additions and 5 deletions

View File

@ -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

20
Cargo.lock generated
View File

@ -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",

View File

@ -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"] }

View File

@ -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};