Skip to content

Commit 84fa538

Browse files
authored
perf(minify): use mimalloc-safe to replace mimalloc (#9810)
This is maintained by us, and it's upgraded to mimalloc 2.2.2. This pr also adds mimalloc to `oxc-minify`
1 parent 754460a commit 84fa538

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

Cargo.lock

Lines changed: 19 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ log = "0.4.25"
197197
markdown = "1.0.0-alpha.22"
198198
memchr = "2.7.4"
199199
miette = { package = "oxc-miette", version = "2.1.2", features = ["fancy-no-syscall"] }
200-
mimalloc = "0.1.43"
200+
mimalloc-safe = "0.1.49"
201201
nonmax = "0.5.5"
202202
num-bigint = "0.4.6"
203203
num-traits = "0.2.19"

apps/oxlint/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ doctest = false
2828
jemallocator = { workspace = true, optional = true }
2929

3030
[target.'cfg(target_os = "windows")'.dependencies]
31-
mimalloc = { workspace = true, optional = true }
31+
mimalloc-safe = { workspace = true, optional = true }
3232

3333
[dependencies]
3434
oxc_diagnostics = { workspace = true }
@@ -52,4 +52,4 @@ regex = { workspace = true }
5252

5353
[features]
5454
default = []
55-
allocator = ["dep:jemallocator", "dep:mimalloc"]
55+
allocator = ["dep:jemallocator", "dep:mimalloc-safe"]

apps/oxlint/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
55

66
#[cfg(all(feature = "allocator", not(miri), target_os = "windows"))]
77
#[global_allocator]
8-
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
8+
static GLOBAL: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc;
99

1010
use oxlint::cli::{CliRunResult, LintRunner, Runner};
1111
use std::io::BufWriter;

napi/minify/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ oxc_syntax = { workspace = true }
3333
napi = { workspace = true }
3434
napi-derive = { workspace = true }
3535

36+
[target.'cfg(all(not(target_os = "linux"), not(target_os = "freebsd"), not(target_arch = "arm"), not(target_family = "wasm")))'.dependencies]
37+
mimalloc-safe = { workspace = true, features = ["skip_collect_on_exit"] }
38+
39+
[target.'cfg(any(all(target_os = "linux", not(target_arch = "arm")), target_os = "freebsd"))'.dependencies]
40+
mimalloc-safe = { workspace = true, features = ["skip_collect_on_exit", "local_dynamic_tls"] }
41+
3642
[package.metadata.cargo-shear]
3743
ignored = ["napi"]
3844

napi/minify/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ use oxc_span::SourceType;
1515

1616
use crate::options::{MinifyOptions, MinifyResult};
1717

18+
#[cfg(all(not(target_arch = "arm"), not(target_family = "wasm")))]
19+
#[global_allocator]
20+
static ALLOC: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc;
21+
1822
/// Minify synchronously.
1923
#[napi]
2024
pub fn minify(

0 commit comments

Comments
 (0)