opt-in jemalloc

This commit is contained in:
Aleksey Kladov 2019-01-28 15:52:21 +03:00
parent 3432c4366f
commit 2ee08098a6
5 changed files with 23 additions and 3 deletions

View file

@ -61,6 +61,7 @@ pub use ra_db::{
// We use jemalloc mainly to get heap usage statistics, actual performance
// differnece is not measures.
#[cfg(feature = "jemalloc")]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

View file

@ -133,6 +133,7 @@ struct MemoryStats {
}
impl MemoryStats {
#[cfg(feature = "jemalloc")]
fn current() -> MemoryStats {
jemalloc_ctl::epoch().unwrap();
MemoryStats {
@ -140,6 +141,14 @@ impl MemoryStats {
resident: Bytes(jemalloc_ctl::stats::resident().unwrap()),
}
}
#[cfg(not(feature = "jemalloc"))]
fn current() -> MemoryStats {
MemoryStats {
allocated: Bytes(0),
resident: Bytes(0),
}
}
}
impl fmt::Display for MemoryStats {