aboutsummaryrefslogtreecommitdiff
path: root/crates
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 /crates
parentdeed44a472edaf11d35fa98c7e68a288f8dfe93f (diff)
Setup global allocator in the correct crate
It worked before, but was roundabout
Diffstat (limited to 'crates')
-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
4 files changed, 5 insertions, 9 deletions
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()? {