From 9ad41eb9085cd7ceaf479f659a7071df81059b7c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 22 Jul 2020 13:42:53 +0200 Subject: Setup global allocator in the correct crate It worked before, but was roundabout --- Cargo.lock | 2 +- crates/ra_prof/Cargo.toml | 2 -- crates/ra_prof/src/lib.rs | 4 ---- crates/rust-analyzer/Cargo.toml | 4 +--- crates/rust-analyzer/src/bin/main.rs | 4 ++++ 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62fd9bfb6..280d97432 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1137,7 +1137,6 @@ dependencies = [ "backtrace", "cfg-if", "libc", - "mimalloc", "once_cell", "ra_arena", ] @@ -1362,6 +1361,7 @@ dependencies = [ "log", "lsp-server", "lsp-types", + "mimalloc", "parking_lot", "pico-args", "ra_cfg", diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index 84d895317..6c214501e 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml @@ -13,7 +13,6 @@ doctest = false ra_arena = { path = "../ra_arena" } once_cell = "1.3.1" backtrace = { version = "0.3.44", optional = true } -mimalloc = { version = "0.1.19", default-features = false, optional = true } cfg-if = "0.1.10" libc = "0.2.73" @@ -22,5 +21,4 @@ cpu_profiler = [] # Uncomment to enable for the whole crate graph # default = [ "backtrace" ] -# default = [ "mimalloc" ] # default = [ "cpu_profiler" ] diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index a5b408a1d..ba5609703 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -13,10 +13,6 @@ pub use crate::{ memory_usage::{Bytes, MemoryUsage}, }; -#[cfg(all(feature = "mimalloc"))] -#[global_allocator] -static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; - /// Prints backtrace to stderr, useful for debugging. #[cfg(feature = "backtrace")] pub fn print_backtrace() { diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 215eeb2f6..023c104d1 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -29,6 +29,7 @@ serde = { version = "1.0.106", features = ["derive"] } serde_json = "1.0.48" threadpool = "1.7.1" rayon = "1.3.1" +mimalloc = { version = "0.1.19", default-features = false, optional = true } stdx = { path = "../stdx" } @@ -62,6 +63,3 @@ expect = { path = "../expect" } test_utils = { path = "../test_utils" } mbe = { path = "../ra_mbe", package = "ra_mbe" } tt = { path = "../ra_tt", package = "ra_tt" } - -[features] -mimalloc = [ "ra_prof/mimalloc" ] diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 408892eab..a473c9165 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -16,6 +16,10 @@ use vfs::AbsPathBuf; use crate::args::HelpPrinted; +#[cfg(all(feature = "mimalloc"))] +#[global_allocator] +static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; + fn main() -> Result<()> { setup_logging()?; let args = match args::Args::parse()? { -- cgit v1.2.3