perf(rome_cli): replace global allocator with jemalloc
MODIFY
Cargo.lock
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"
@@ -1507,6 +1513,7 @@ dependencies = [
"serde",
"serde_json",
"thiserror",
+ "tikv-jemallocator",
"tokio",
"tracing",
"tracing-appender",
@@ -2181,6 +2188,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"
@@ -2822,6 +2850,7 @@ dependencies = [
"rome_js_formatter",
"rome_js_parser",
"rome_js_syntax",
+ "tikv-jemallocator",
"timing",
"ureq",
"url",

MODIFY
crates/rome_cli/Cargo.toml
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"] }

MODIFY
crates/rome_cli/src/main.rs
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();

MODIFY
xtask/bench/Cargo.toml
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"]

MODIFY
xtask/bench/src/main.rs
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();

perf(rome_cli): replace global allocator with jemalloc (#3237)