diff options
Diffstat (limited to 'crates/ra_prof')
-rw-r--r-- | crates/ra_prof/Cargo.toml | 6 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_prof/src/memory_usage.rs | 10 |
3 files changed, 2 insertions, 20 deletions
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index 2e60858f1..84d895317 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml | |||
@@ -17,16 +17,10 @@ mimalloc = { version = "0.1.19", default-features = false, optional = true } | |||
17 | cfg-if = "0.1.10" | 17 | cfg-if = "0.1.10" |
18 | libc = "0.2.73" | 18 | libc = "0.2.73" |
19 | 19 | ||
20 | [target.'cfg(not(target_env = "msvc"))'.dependencies] | ||
21 | jemallocator = { version = "0.3.2", optional = true } | ||
22 | jemalloc-ctl = { version = "0.3.3", optional = true } | ||
23 | |||
24 | [features] | 20 | [features] |
25 | jemalloc = [ "jemallocator", "jemalloc-ctl" ] | ||
26 | cpu_profiler = [] | 21 | cpu_profiler = [] |
27 | 22 | ||
28 | # Uncomment to enable for the whole crate graph | 23 | # Uncomment to enable for the whole crate graph |
29 | # default = [ "backtrace" ] | 24 | # default = [ "backtrace" ] |
30 | # default = [ "jemalloc" ] | ||
31 | # default = [ "mimalloc" ] | 25 | # default = [ "mimalloc" ] |
32 | # default = [ "cpu_profiler" ] | 26 | # default = [ "cpu_profiler" ] |
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index b54531b4e..a5b408a1d 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -13,12 +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] | ||
20 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
21 | |||
22 | #[cfg(all(feature = "mimalloc"))] | 16 | #[cfg(all(feature = "mimalloc"))] |
23 | #[global_allocator] | 17 | #[global_allocator] |
24 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | 18 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; |
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 |
2 | use std::fmt; | ||
2 | 3 | ||
3 | use cfg_if::cfg_if; | 4 | use cfg_if::cfg_if; |
4 | use std::fmt; | ||
5 | 5 | ||
6 | pub struct MemoryUsage { | 6 | pub struct MemoryUsage { |
7 | pub allocated: Bytes, | 7 | pub allocated: Bytes, |
@@ -11,13 +11,7 @@ pub struct MemoryUsage { | |||
11 | impl MemoryUsage { | 11 | impl 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) } |