feat: replace the system allocator with mimalloc on Windows
MODIFY
Cargo.lock
Cargo.lock
@@ -845,6 +845,15 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "libmimalloc-sys"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11ca136052550448f55df7898c6dbe651c6b574fe38a0d9ea687a9f8088a2e2c"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "libz-sys"
version = "1.1.3"
@@ -924,6 +933,15 @@ dependencies = [
"autocfg",
]
+[[package]]
+name = "mimalloc"
+version = "0.1.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f64ad83c969af2e732e907564deb0d0ed393cec4af80776f77dd77a1a427698"
+dependencies = [
+ "libmimalloc-sys",
+]
+
[[package]]
name = "miniz_oxide"
version = "0.4.4"
@@ -1336,6 +1354,7 @@ dependencies = [
"crossbeam",
"hdrhistogram",
"lazy_static",
+ "mimalloc",
"parking_lot",
"pico-args",
"rayon",
@@ -1549,6 +1568,7 @@ dependencies = [
"anyhow",
"futures",
"indexmap",
+ "mimalloc",
"parking_lot",
"rome_analyze",
"rome_console",
@@ -2485,6 +2505,7 @@ dependencies = [
"dhat",
"humansize",
"itertools",
+ "mimalloc",
"pico-args",
"regex",
"rome_analyze",

MODIFY
crates/rome_cli/Cargo.toml
crates/rome_cli/Cargo.toml
@@ -23,3 +23,6 @@ hdrhistogram = { version = "7.5.0", default-features = false }
crossbeam = "0.8.1"
thiserror = "1.0.30"
rayon = "1.5.1"
+
+[target.'cfg(target_os = "windows")'.dependencies]
+mimalloc = "0.1.29"

MODIFY
crates/rome_cli/src/bin/rome.rs
crates/rome_cli/src/bin/rome.rs
use rome_cli::{run_cli, setup_panic_handler, CliSession, Termination};
+#[cfg(target_os = "windows")]
+#[global_allocator]
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
///
/// To run this example, run:
///

MODIFY
crates/rome_lsp/Cargo.toml
crates/rome_lsp/Cargo.toml
@@ -29,5 +29,8 @@ tracing-subscriber = "0.3.5"
parking_lot = "0.12.0"
futures = "0.3"
+[target.'cfg(target_os = "windows")'.dependencies]
+mimalloc = "0.1.29"
+
[dev-dependencies]
tower = { version = "0.4.12", features = ["timeout"] }

MODIFY
crates/rome_lsp/src/main.rs
crates/rome_lsp/src/main.rs
@@ -4,6 +4,10 @@ use tracing_tree::HierarchicalLayer;
use rome_lsp::server::run_server;
+#[cfg(target_os = "windows")]
+#[global_allocator]
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
#[tokio::main]
async fn main() {
let stdin = tokio::io::stdin();

MODIFY
xtask/bench/Cargo.toml
xtask/bench/Cargo.toml
@@ -23,6 +23,9 @@ url = "2.2.2"
itertools = "0.10.3"
ansi_rgb = "0.2.0"
+[target.'cfg(target_os = "windows")'.dependencies]
+mimalloc = "0.1.29"
+
# dhat-on
dhat = { version = "0.2.4", optional = true }
humansize = {version = "1.1.1", optional = true }

MODIFY
xtask/bench/src/main.rs
xtask/bench/src/main.rs
@@ -9,6 +9,10 @@ use dhat::DhatAlloc;
#[global_allocator]
static ALLOCATOR: DhatAlloc = DhatAlloc;
+#[cfg(all(target_os = "windows", not(feature = "dhat-on")))]
+#[global_allocator]
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
fn main() -> Result<(), pico_args::Error> {
#[cfg(feature = "dhat-on")]
let _dhat = dhat::Dhat::start_heap_profiling();

feat: replace the system allocator with mimalloc on Windows (#2900)