Skip to content

Commit

Permalink
perf: Use mimalloc on linux (#10113)
Browse files Browse the repository at this point in the history
**Description:**

It's more performant than jemalloc.
  • Loading branch information
kdy1 authored Feb 27, 2025
1 parent cff6a64 commit 3334932
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .changeset/calm-pillows-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: minor
swc_malloc: minor
---

perf: Use `mimalloc` on linux
21 changes: 0 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/swc_malloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ bench = false

[dependencies]

[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc = { version = "0.1" }
[target.'cfg(not(any(target_os = "linux", target_family = "wasm", target_env = "musl")))'.dependencies]
mimalloc = { version = "0.1.43", features = [] }

[target.'cfg(all(target_os = "linux", target_env = "gnu", any(target_arch = "x86_64", target_arch = "aarch64")))'.dependencies]
tikv-jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] }
[target.'cfg(all(target_os = "linux", not(any(target_family = "wasm", target_env = "musl"))))'.dependencies]
mimalloc = { version = "0.1.43", features = ["local_dynamic_tls"] }
10 changes: 1 addition & 9 deletions crates/swc_malloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
//!
//! The swc crates related to the node binding should depend on this crate.
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_family = "wasm", target_env = "musl")))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(all(
target_os = "linux",
target_env = "gnu",
any(target_arch = "x86_64", target_arch = "aarch64")
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

0 comments on commit 3334932

Please sign in to comment.