aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_prof/Cargo.toml8
-rw-r--r--crates/ra_prof/src/lib.rs10
-rw-r--r--crates/ra_prof/src/memory_usage.rs10
-rw-r--r--crates/rust-analyzer/Cargo.toml5
-rw-r--r--crates/rust-analyzer/src/bin/args.rs4
-rw-r--r--crates/rust-analyzer/src/bin/main.rs4
6 files changed, 9 insertions, 32 deletions
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml
index 2e60858f1..6c214501e 100644
--- a/crates/ra_prof/Cargo.toml
+++ b/crates/ra_prof/Cargo.toml
@@ -13,20 +13,12 @@ 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
20[target.'cfg(not(target_env = "msvc"))'.dependencies]
21jemallocator = { version = "0.3.2", optional = true }
22jemalloc-ctl = { version = "0.3.3", optional = true }
23
24[features] 19[features]
25jemalloc = [ "jemallocator", "jemalloc-ctl" ]
26cpu_profiler = [] 20cpu_profiler = []
27 21
28# Uncomment to enable for the whole crate graph 22# Uncomment to enable for the whole crate graph
29# default = [ "backtrace" ] 23# default = [ "backtrace" ]
30# default = [ "jemalloc" ]
31# default = [ "mimalloc" ]
32# default = [ "cpu_profiler" ] 24# default = [ "cpu_profiler" ]
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index b54531b4e..ba5609703 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -13,16 +13,6 @@ pub use crate::{
13 memory_usage::{Bytes, MemoryUsage}, 13 memory_usage::{Bytes, MemoryUsage},
14}; 14};
15 15
16// We use jemalloc mainly to get heap usage statistics, actual performance
17// difference is not measures.
18#[cfg(all(feature = "jemalloc", not(target_env = "msvc")))]
19#[global_allocator]
20static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
21
22#[cfg(all(feature = "mimalloc"))]
23#[global_allocator]
24static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
25
26/// Prints backtrace to stderr, useful for debugging. 16/// Prints backtrace to stderr, useful for debugging.
27#[cfg(feature = "backtrace")] 17#[cfg(feature = "backtrace")]
28pub fn print_backtrace() { 18pub fn print_backtrace() {
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs
index b1858b06f..ee79ec3ee 100644
--- a/crates/ra_prof/src/memory_usage.rs
+++ b/crates/ra_prof/src/memory_usage.rs
@@ -1,7 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2use std::fmt;
2 3
3use cfg_if::cfg_if; 4use cfg_if::cfg_if;
4use std::fmt;
5 5
6pub struct MemoryUsage { 6pub struct MemoryUsage {
7 pub allocated: Bytes, 7 pub allocated: Bytes,
@@ -11,13 +11,7 @@ pub struct MemoryUsage {
11impl MemoryUsage { 11impl MemoryUsage {
12 pub fn current() -> MemoryUsage { 12 pub fn current() -> MemoryUsage {
13 cfg_if! { 13 cfg_if! {
14 if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { 14 if #[cfg(target_os = "linux")] {
15 jemalloc_ctl::epoch::advance().unwrap();
16 MemoryUsage {
17 allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap()),
18 resident: Bytes(jemalloc_ctl::stats::resident::read().unwrap()),
19 }
20 } else if #[cfg(target_os = "linux")] {
21 // Note: This is incredibly slow. 15 // Note: This is incredibly slow.
22 let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize; 16 let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize;
23 MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) } 17 MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) }
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 5eb2d0bb7..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,7 +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]
67jemalloc = [ "ra_prof/jemalloc" ]
68mimalloc = [ "ra_prof/mimalloc" ]
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs
index 3210416ee..741a2a951 100644
--- a/crates/rust-analyzer/src/bin/args.rs
+++ b/crates/rust-analyzer/src/bin/args.rs
@@ -166,7 +166,7 @@ USAGE:
166FLAGS: 166FLAGS:
167 -o, --only Only analyze items matching this path 167 -o, --only Only analyze items matching this path
168 -h, --help Prints help information 168 -h, --help Prints help information
169 --memory-usage Collect memory usage statistics (requires `--features jemalloc`) 169 --memory-usage Collect memory usage statistics
170 --randomize Randomize order in which crates, modules, and items are processed 170 --randomize Randomize order in which crates, modules, and items are processed
171 --parallel Run type inference in parallel 171 --parallel Run type inference in parallel
172 --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis 172 --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis
@@ -221,7 +221,7 @@ USAGE:
221 221
222FLAGS: 222FLAGS:
223 -h, --help Prints help information 223 -h, --help Prints help information
224 --memory-usage Collect memory usage statistics (requires `--features jemalloc`) 224 --memory-usage Collect memory usage statistics
225 --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis 225 --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis
226 --with-proc-macro Use ra-proc-macro-srv for proc-macro expanding 226 --with-proc-macro Use ra-proc-macro-srv for proc-macro expanding
227 -v, --verbose 227 -v, --verbose
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()? {