diff --git a/Cargo.lock b/Cargo.lock index ad791ad4aed..4ac78285f64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -547,6 +547,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + [[package]] name = "fst" version = "0.4.7" @@ -1498,6 +1504,7 @@ dependencies = [ "serde", "serde_json", "thiserror", + "tikv-jemallocator", "tokio", "tracing", "tracing-appender", @@ -2171,6 +2178,27 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.1+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "931e876f91fed0827f863a2d153897790da0b24d882c721a79cb3beb0b903261" +dependencies = [ + "cc", + "fs_extra", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.13" @@ -2804,6 +2832,7 @@ dependencies = [ "rome_js_formatter", "rome_js_parser", "rome_js_syntax", + "tikv-jemallocator", "timing", "ureq", "url", diff --git a/crates/rome_cli/Cargo.toml b/crates/rome_cli/Cargo.toml index c5fd27067cc..776fc7b55a8 100644 --- a/crates/rome_cli/Cargo.toml +++ b/crates/rome_cli/Cargo.toml @@ -42,6 +42,9 @@ tokio = { version = "1.15.0", features = ["process"] } [target.'cfg(windows)'.dependencies] mimalloc = "0.1.29" +[target.'cfg(not(windows))'.dependencies] +tikv-jemallocator = "0.5.0" + [dev-dependencies] insta = "1.18.2" tokio = { version = "1.15.0", features = ["io-util"] } diff --git a/crates/rome_cli/src/main.rs b/crates/rome_cli/src/main.rs index a55a4f9128d..35350b59cfc 100644 --- a/crates/rome_cli/src/main.rs +++ b/crates/rome_cli/src/main.rs @@ -12,6 +12,10 @@ use tokio::runtime::Runtime; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +#[cfg(not(target_os = "windows"))] +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + fn main() -> Result<(), Termination> { setup_panic_handler(); diff --git a/xtask/bench/Cargo.toml b/xtask/bench/Cargo.toml index 1b3ecca3780..ebe77d3f59a 100644 --- a/xtask/bench/Cargo.toml +++ b/xtask/bench/Cargo.toml @@ -30,5 +30,8 @@ humansize = {version = "1.1.1", optional = true } [target.'cfg(target_os = "windows")'.dependencies] mimalloc = "0.1.29" +[target.'cfg(not(windows))'.dependencies] +tikv-jemallocator = "0.5.0" + [features] dhat-heap = ["dhat", "humansize"] diff --git a/xtask/bench/src/main.rs b/xtask/bench/src/main.rs index a13a4135b0e..3efd4b03013 100644 --- a/xtask/bench/src/main.rs +++ b/xtask/bench/src/main.rs @@ -10,6 +10,10 @@ static ALLOCATOR: dhat::Alloc = dhat::Alloc; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +#[cfg(all(not(target_os = "windows"), not(feature = "dhat-heap")))] +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + fn main() -> Result<(), pico_args::Error> { #[cfg(feature = "dhat-heap")] let _profiler = dhat::Profiler::new_heap();