aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-22 12:42:53 +0100
committerAleksey Kladov <[email protected]>2020-07-22 12:42:53 +0100
commit9ad41eb9085cd7ceaf479f659a7071df81059b7c (patch)
tree6dfcadbf3b6a333777f22f54db773118bf1916d4
parentdeed44a472edaf11d35fa98c7e68a288f8dfe93f (diff)
Setup global allocator in the correct crate
It worked before, but was roundabout
-rw-r--r--Cargo.lock2
-rw-r--r--crates/ra_prof/Cargo.toml2
-rw-r--r--crates/ra_prof/src/lib.rs4
-rw-r--r--crates/rust-analyzer/Cargo.toml4
-rw-r--r--crates/rust-analyzer/src/bin/main.rs4
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 = [
1137 "backtrace", 1137 "backtrace",
1138 "cfg-if", 1138 "cfg-if",
1139 "libc", 1139 "libc",
1140 "mimalloc",
1141 "once_cell", 1140 "once_cell",
1142 "ra_arena", 1141 "ra_arena",
1143] 1142]
@@ -1362,6 +1361,7 @@ dependencies = [
1362 "log", 1361 "log",
1363 "lsp-server", 1362 "lsp-server",
1364 "lsp-types", 1363 "lsp-types",
1364 "mimalloc",
1365 "parking_lot", 1365 "parking_lot",
1366 "pico-args", 1366 "pico-args",
1367 "ra_cfg", 1367 "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
13ra_arena = { path = "../ra_arena" } 13ra_arena = { path = "../ra_arena" }
14once_cell = "1.3.1" 14once_cell = "1.3.1"
15backtrace = { version = "0.3.44", optional = true } 15backtrace = { version = "0.3.44", optional = true }
16mimalloc = { version = "0.1.19", default-features = false, optional = true }
17cfg-if = "0.1.10" 16cfg-if = "0.1.10"
18libc = "0.2.73" 17libc = "0.2.73"
19 18
@@ -22,5 +21,4 @@ cpu_profiler = []
22 21
23# Uncomment to enable for the whole crate graph 22# Uncomment to enable for the whole crate graph
24# default = [ "backtrace" ] 23# default = [ "backtrace" ]
25# default = [ "mimalloc" ]
26# default = [ "cpu_profiler" ] 24# 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::{
13 memory_usage::{Bytes, MemoryUsage}, 13 memory_usage::{Bytes, MemoryUsage},
14}; 14};
15 15
16#[cfg(all(feature = "mimalloc"))]
17#[global_allocator]
18static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
19
20/// Prints backtrace to stderr, useful for debugging. 16/// Prints backtrace to stderr, useful for debugging.
21#[cfg(feature = "backtrace")] 17#[cfg(feature = "backtrace")]
22pub fn print_backtrace() { 18pub 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"] }
29serde_json = "1.0.48" 29serde_json = "1.0.48"
30threadpool = "1.7.1" 30threadpool = "1.7.1"
31rayon = "1.3.1" 31rayon = "1.3.1"
32mimalloc = { version = "0.1.19", default-features = false, optional = true }
32 33
33stdx = { path = "../stdx" } 34stdx = { path = "../stdx" }
34 35
@@ -62,6 +63,3 @@ expect = { path = "../expect" }
62test_utils = { path = "../test_utils" } 63test_utils = { path = "../test_utils" }
63mbe = { path = "../ra_mbe", package = "ra_mbe" } 64mbe = { path = "../ra_mbe", package = "ra_mbe" }
64tt = { path = "../ra_tt", package = "ra_tt" } 65tt = { path = "../ra_tt", package = "ra_tt" }
65
66[features]
67mimalloc = [ "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;
16 16
17use crate::args::HelpPrinted; 17use crate::args::HelpPrinted;
18 18
19#[cfg(all(feature = "mimalloc"))]
20#[global_allocator]
21static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
22
19fn main() -> Result<()> { 23fn main() -> Result<()> {
20 setup_logging()?; 24 setup_logging()?;
21 let args = match args::Args::parse()? { 25 let args = match args::Args::parse()? {