From deed44a472edaf11d35fa98c7e68a288f8dfe93f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 22 Jul 2020 13:40:45 +0200 Subject: Remove support for jemalloc We only used it for measuring memory usage, but now we can use glibc's allocator for that just fine --- crates/ra_prof/Cargo.toml | 6 ------ crates/ra_prof/src/lib.rs | 6 ------ crates/ra_prof/src/memory_usage.rs | 10 ++-------- 3 files changed, 2 insertions(+), 20 deletions(-) (limited to 'crates/ra_prof') 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 } cfg-if = "0.1.10" libc = "0.2.73" -[target.'cfg(not(target_env = "msvc"))'.dependencies] -jemallocator = { version = "0.3.2", optional = true } -jemalloc-ctl = { version = "0.3.3", optional = true } - [features] -jemalloc = [ "jemallocator", "jemalloc-ctl" ] cpu_profiler = [] # Uncomment to enable for the whole crate graph # default = [ "backtrace" ] -# default = [ "jemalloc" ] # default = [ "mimalloc" ] # 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::{ memory_usage::{Bytes, MemoryUsage}, }; -// We use jemalloc mainly to get heap usage statistics, actual performance -// difference is not measures. -#[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] -#[global_allocator] -static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; - #[cfg(all(feature = "mimalloc"))] #[global_allocator] 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 @@ //! FIXME: write short doc here +use std::fmt; use cfg_if::cfg_if; -use std::fmt; pub struct MemoryUsage { pub allocated: Bytes, @@ -11,13 +11,7 @@ pub struct MemoryUsage { impl MemoryUsage { pub fn current() -> MemoryUsage { cfg_if! { - if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { - jemalloc_ctl::epoch::advance().unwrap(); - MemoryUsage { - allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap()), - resident: Bytes(jemalloc_ctl::stats::resident::read().unwrap()), - } - } else if #[cfg(target_os = "linux")] { + if #[cfg(target_os = "linux")] { // Note: This is incredibly slow. let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize; MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) } -- cgit v1.2.3 From 9ad41eb9085cd7ceaf479f659a7071df81059b7c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 22 Jul 2020 13:42:53 +0200 Subject: Setup global allocator in the correct crate It worked before, but was roundabout --- crates/ra_prof/Cargo.toml | 2 -- crates/ra_prof/src/lib.rs | 4 ---- 2 files changed, 6 deletions(-) (limited to 'crates/ra_prof') 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 ra_arena = { path = "../ra_arena" } once_cell = "1.3.1" backtrace = { version = "0.3.44", optional = true } -mimalloc = { version = "0.1.19", default-features = false, optional = true } cfg-if = "0.1.10" libc = "0.2.73" @@ -22,5 +21,4 @@ cpu_profiler = [] # Uncomment to enable for the whole crate graph # default = [ "backtrace" ] -# default = [ "mimalloc" ] # 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::{ memory_usage::{Bytes, MemoryUsage}, }; -#[cfg(all(feature = "mimalloc"))] -#[global_allocator] -static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; - /// Prints backtrace to stderr, useful for debugging. #[cfg(feature = "backtrace")] pub fn print_backtrace() { -- cgit v1.2.3