diff options
author | Aleksey Kladov <[email protected]> | 2020-07-22 12:42:53 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-22 12:42:53 +0100 |
commit | 9ad41eb9085cd7ceaf479f659a7071df81059b7c (patch) | |
tree | 6dfcadbf3b6a333777f22f54db773118bf1916d4 | |
parent | deed44a472edaf11d35fa98c7e68a288f8dfe93f (diff) |
Setup global allocator in the correct crate
It worked before, but was roundabout
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | crates/ra_prof/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 4 | ||||
-rw-r--r-- | 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 = [ | |||
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 | |||
13 | ra_arena = { path = "../ra_arena" } | 13 | ra_arena = { path = "../ra_arena" } |
14 | once_cell = "1.3.1" | 14 | once_cell = "1.3.1" |
15 | backtrace = { version = "0.3.44", optional = true } | 15 | backtrace = { version = "0.3.44", optional = true } |
16 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | ||
17 | cfg-if = "0.1.10" | 16 | cfg-if = "0.1.10" |
18 | libc = "0.2.73" | 17 | libc = "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] | ||
18 | static 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")] |
22 | pub fn print_backtrace() { | 18 | 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"] } | |||
29 | serde_json = "1.0.48" | 29 | serde_json = "1.0.48" |
30 | threadpool = "1.7.1" | 30 | threadpool = "1.7.1" |
31 | rayon = "1.3.1" | 31 | rayon = "1.3.1" |
32 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | ||
32 | 33 | ||
33 | stdx = { path = "../stdx" } | 34 | stdx = { path = "../stdx" } |
34 | 35 | ||
@@ -62,6 +63,3 @@ expect = { path = "../expect" } | |||
62 | test_utils = { path = "../test_utils" } | 63 | test_utils = { path = "../test_utils" } |
63 | mbe = { path = "../ra_mbe", package = "ra_mbe" } | 64 | mbe = { path = "../ra_mbe", package = "ra_mbe" } |
64 | tt = { path = "../ra_tt", package = "ra_tt" } | 65 | tt = { path = "../ra_tt", package = "ra_tt" } |
65 | |||
66 | [features] | ||
67 | 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; | |||
16 | 16 | ||
17 | use crate::args::HelpPrinted; | 17 | use crate::args::HelpPrinted; |
18 | 18 | ||
19 | #[cfg(all(feature = "mimalloc"))] | ||
20 | #[global_allocator] | ||
21 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | ||
22 | |||
19 | fn main() -> Result<()> { | 23 | fn main() -> Result<()> { |
20 | setup_logging()?; | 24 | setup_logging()?; |
21 | let args = match args::Args::parse()? { | 25 | let args = match args::Args::parse()? { |