From bb39ada66fec3e205f379c1b19fcb9ab341905b9 Mon Sep 17 00:00:00 2001 From: ematipico Date: Fri, 16 Sep 2022 08:51:06 +0100 Subject: [PATCH 1/2] perf: jamalloc --- Cargo.lock | 29 +++++++++++++++++++++++++++++ crates/rome_cli/Cargo.toml | 3 +++ crates/rome_cli/src/main.rs | 4 ++++ xtask/bench/Cargo.toml | 3 +++ xtask/bench/src/main.rs | 4 ++++ 5 files changed, 43 insertions(+) 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..2f83bd7c1f8 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(target_os = "macos")'.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..0b811534537 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(target_os = "macos")] +#[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..9927fe047af 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(target_os = "macos")'.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..1afa6efd936 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(target_os = "macos", 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(); From 3e557de864762effa5e48ebd10a6b55a9671f692 Mon Sep 17 00:00:00 2001 From: ematipico Date: Tue, 20 Sep 2022 13:14:35 +0100 Subject: [PATCH 2/2] chore: enable allocator in linux --- crates/rome_cli/Cargo.toml | 2 +- crates/rome_cli/src/main.rs | 2 +- xtask/bench/Cargo.toml | 2 +- xtask/bench/src/main.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/rome_cli/Cargo.toml b/crates/rome_cli/Cargo.toml index 2f83bd7c1f8..776fc7b55a8 100644 --- a/crates/rome_cli/Cargo.toml +++ b/crates/rome_cli/Cargo.toml @@ -42,7 +42,7 @@ tokio = { version = "1.15.0", features = ["process"] } [target.'cfg(windows)'.dependencies] mimalloc = "0.1.29" -[target.'cfg(target_os = "macos")'.dependencies] +[target.'cfg(not(windows))'.dependencies] tikv-jemallocator = "0.5.0" [dev-dependencies] diff --git a/crates/rome_cli/src/main.rs b/crates/rome_cli/src/main.rs index 0b811534537..35350b59cfc 100644 --- a/crates/rome_cli/src/main.rs +++ b/crates/rome_cli/src/main.rs @@ -12,7 +12,7 @@ use tokio::runtime::Runtime; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(target_os = "macos")] +#[cfg(not(target_os = "windows"))] #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; diff --git a/xtask/bench/Cargo.toml b/xtask/bench/Cargo.toml index 9927fe047af..ebe77d3f59a 100644 --- a/xtask/bench/Cargo.toml +++ b/xtask/bench/Cargo.toml @@ -30,7 +30,7 @@ humansize = {version = "1.1.1", optional = true } [target.'cfg(target_os = "windows")'.dependencies] mimalloc = "0.1.29" -[target.'cfg(target_os = "macos")'.dependencies] +[target.'cfg(not(windows))'.dependencies] tikv-jemallocator = "0.5.0" [features] diff --git a/xtask/bench/src/main.rs b/xtask/bench/src/main.rs index 1afa6efd936..3efd4b03013 100644 --- a/xtask/bench/src/main.rs +++ b/xtask/bench/src/main.rs @@ -10,7 +10,7 @@ static ALLOCATOR: dhat::Alloc = dhat::Alloc; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(all(target_os = "macos", not(feature = "dhat-heap")))] +#[cfg(all(not(target_os = "windows"), not(feature = "dhat-heap")))] #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;