Even if jemalloc feature is used do not use it on msvc

Fixes #2233
This commit is contained in:
kjeremy 2019-11-14 11:47:18 -05:00
parent f2c64ba15d
commit fc9c2915c7
3 changed files with 22 additions and 20 deletions

View file

@ -1,17 +1,19 @@
[package]
edition = "2018"
name = "ra_prof"
version = "0.1.0"
authors = ["rust-analyzer developers"]
publish = false
[dependencies]
once_cell = "1.0.1"
itertools = "0.8.0"
backtrace = "0.3.28"
jemallocator = { version = "0.3.2", optional = true }
jemalloc-ctl = { version = "0.3.2", optional = true }
[features]
jemalloc = [ "jemallocator", "jemalloc-ctl" ]
cpu_profiler = []
[package]
edition = "2018"
name = "ra_prof"
version = "0.1.0"
authors = ["rust-analyzer developers"]
publish = false
[dependencies]
once_cell = "1.0.1"
itertools = "0.8.0"
backtrace = "0.3.28"
[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = { version = "0.3.2", optional = true }
jemalloc-ctl = { version = "0.3.2", optional = true }
[features]
jemalloc = [ "jemallocator", "jemalloc-ctl" ]
cpu_profiler = []

View file

@ -24,7 +24,7 @@ pub use crate::memory_usage::{Bytes, MemoryUsage};
// We use jemalloc mainly to get heap usage statistics, actual performance
// difference is not measures.
#[cfg(feature = "jemalloc")]
#[cfg(all(feature = "jemalloc", not(target_env = "msvc")))]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

View file

@ -8,7 +8,7 @@ pub struct MemoryUsage {
}
impl MemoryUsage {
#[cfg(feature = "jemalloc")]
#[cfg(all(feature = "jemalloc", not(target_env = "msvc")))]
pub fn current() -> MemoryUsage {
jemalloc_ctl::epoch::advance().unwrap();
MemoryUsage {
@ -17,7 +17,7 @@ impl MemoryUsage {
}
}
#[cfg(not(feature = "jemalloc"))]
#[cfg(any(not(feature = "jemalloc"), target_env = "msvc"))]
pub fn current() -> MemoryUsage {
MemoryUsage { allocated: Bytes(0), resident: Bytes(0) }
}