Unverified Commit e13100a7 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

[Backport] mimalloc upgrade and enabling it on musl (#88503)

Co-authored-by: 's avatarxusd320 <xusd320@gmail.com>
parent beb3a766
...@@ -3642,6 +3642,17 @@ dependencies = [ ...@@ -3642,6 +3642,17 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "libmimalloc-sys"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "667f4fec20f29dfc6bc7357c582d91796c169ad7e2fce709468aefeb2c099870"
dependencies = [
"cc",
"cty",
"libc",
]
[[package]] [[package]]
name = "libunwind" name = "libunwind"
version = "1.3.3" version = "1.3.3"
...@@ -3997,12 +4008,12 @@ dependencies = [ ...@@ -3997,12 +4008,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "mimalloc-rspack" name = "mimalloc"
version = "0.2.4" version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de20bb33bf95d9c060030d53bcb5d5dc03cbbedfbd1dcda5f6f285b946dae2c0" checksum = "e1ee66a4b64c74f4ef288bcbb9192ad9c3feaad75193129ac8509af543894fd8"
dependencies = [ dependencies = [
"rspack-libmimalloc-sys", "libmimalloc-sys",
] ]
[[package]] [[package]]
...@@ -6042,17 +6053,6 @@ dependencies = [ ...@@ -6042,17 +6053,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "rspack-libmimalloc-sys"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c741844b1fbe0cfbae8dfeb73b5e5fdc95daf7be58bdd72afb3fd85c86bccdb"
dependencies = [
"cc",
"cty",
"libc",
]
[[package]] [[package]]
name = "rstest" name = "rstest"
version = "0.16.0" version = "0.16.0"
...@@ -9437,8 +9437,7 @@ dependencies = [ ...@@ -9437,8 +9437,7 @@ dependencies = [
name = "turbo-tasks-malloc" name = "turbo-tasks-malloc"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"mimalloc-rspack", "mimalloc",
"rspack-libmimalloc-sys",
] ]
[[package]] [[package]]
......
...@@ -10,21 +10,21 @@ autobenches = false ...@@ -10,21 +10,21 @@ autobenches = false
bench = false bench = false
[dependencies] [dependencies]
rspack-libmimalloc-sys = { version = "0.2.4", default-features = false, features = [], optional = true }
[target.'cfg(not(any(target_os = "linux", target_family = "wasm", target_env = "musl")))'.dependencies]
mimalloc-rspack = { version = "0.2.4", features = [ [target.'cfg(not(any(target_os = "linux", target_family = "wasm")))'.dependencies]
mimalloc = { version = "0.1.48", features = [
"v3", "v3",
"extended" "extended",
], optional = true } ], optional = true }
[target.'cfg(all(target_os = "linux", not(any(target_family = "wasm", target_env = "musl"))))'.dependencies] [target.'cfg(all(target_os = "linux", not(target_family = "wasm")))'.dependencies]
mimalloc-rspack = { version = "0.2.4", features = [ mimalloc = { version = "0.1.48", features = [
"v3", "v3",
"extended", "extended",
"local_dynamic_tls", "local_dynamic_tls",
], optional = true } ], optional = true }
[features] [features]
custom_allocator = ["dep:mimalloc-rspack", "dep:rspack-libmimalloc-sys"] custom_allocator = ["dep:mimalloc"]
default = ["custom_allocator"] default = ["custom_allocator"]
...@@ -114,29 +114,17 @@ impl TurboMalloc { ...@@ -114,29 +114,17 @@ impl TurboMalloc {
/// Get the allocator for this platform that we should wrap with TurboMalloc. /// Get the allocator for this platform that we should wrap with TurboMalloc.
#[inline] #[inline]
fn base_alloc() -> &'static impl GlobalAlloc { fn base_alloc() -> &'static impl GlobalAlloc {
#[cfg(all( #[cfg(all(feature = "custom_allocator", not(target_family = "wasm")))]
feature = "custom_allocator", return &mimalloc::MiMalloc;
not(any(target_family = "wasm", target_env = "musl")) #[cfg(not(all(feature = "custom_allocator", not(target_family = "wasm"))))]
))]
return &mimalloc_rspack::MiMalloc;
#[cfg(any(
not(feature = "custom_allocator"),
any(target_family = "wasm", target_env = "musl")
))]
return &std::alloc::System; return &std::alloc::System;
} }
#[allow(unused_variables)] #[allow(unused_variables)]
unsafe fn base_alloc_size(ptr: *const u8, layout: Layout) -> usize { unsafe fn base_alloc_size(ptr: *const u8, layout: Layout) -> usize {
#[cfg(all( #[cfg(all(feature = "custom_allocator", not(target_family = "wasm")))]
feature = "custom_allocator", return unsafe { mimalloc::MiMalloc.usable_size(ptr) };
not(any(target_family = "wasm", target_env = "musl")) #[cfg(not(all(feature = "custom_allocator", not(target_family = "wasm"))))]
))]
return unsafe { mimalloc_rspack::MiMalloc.usable_size(ptr) };
#[cfg(any(
not(feature = "custom_allocator"),
any(target_family = "wasm", target_env = "musl")
))]
return layout.size(); return layout.size();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment