fix(node): Use jemallocator on linux (#4591)

This commit is contained in:
LongYinan 2022-05-10 00:59:59 +08:00 committed by GitHub
parent ba406f6120
commit af91094b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 5 deletions

28
Cargo.lock generated
View File

@ -952,6 +952,12 @@ dependencies = [
"syn",
]
[[package]]
name = "fs_extra"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
[[package]]
name = "futures-channel"
version = "0.3.19"
@ -3918,6 +3924,7 @@ name = "swc_node_base"
version = "0.5.2"
dependencies = [
"mimalloc-rust",
"tikv-jemallocator",
]
[[package]]
@ -4209,6 +4216,27 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tikv-jemalloc-sys"
version = "0.4.3+5.2.1-patched.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1792ccb507d955b46af42c123ea8863668fae24d03721e40cad6a41773dbb49"
dependencies = [
"cc",
"fs_extra",
"libc",
]
[[package]]
name = "tikv-jemallocator"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5b7bcecfafe4998587d636f9ae9d55eb9d0499877b88757767c346875067098"
dependencies = [
"libc",
"tikv-jemalloc-sys",
]
[[package]]
name = "time"
version = "0.1.43"

View File

@ -13,5 +13,8 @@ bench = false
[dependencies]
[target.'cfg(not(all(target_os = "linux", target_arch = "aarch64", target_env = "musl")))'.dependencies]
mimalloc-rust = "=0.1.5"
[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc-rust = { version = "0.1" }
[target.'cfg(all(target_os = "linux", target_env = "gnu", all(target_arch = "x86_64", target_arch = "aarch64")))'.dependencies]
tikv-jemallocator = { version = "0.4", features = ["disable_initial_exec_tls"] }

View File

@ -2,9 +2,14 @@
//!
//! The swc crates related to the node binding should depend on this crate.
#[cfg(not(target_os = "linux"))]
#[global_allocator]
static GLOBAL: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;
#[cfg(all(
not(debug_assertions),
not(all(target_os = "linux", target_arch = "aarch64", target_env = "musl")),
target_os = "linux",
target_env = "gnu",
all(target_arch = "x86_64", target_arch = "aarch64")
))]
#[global_allocator]
static ALLOC: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;