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 ++-------- crates/rust-analyzer/Cargo.toml | 1 - crates/rust-analyzer/src/bin/args.rs | 4 ++-- 5 files changed, 4 insertions(+), 23 deletions(-) (limited to 'crates') 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) } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 5eb2d0bb7..215eeb2f6 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -64,5 +64,4 @@ mbe = { path = "../ra_mbe", package = "ra_mbe" } tt = { path = "../ra_tt", package = "ra_tt" } [features] -jemalloc = [ "ra_prof/jemalloc" ] mimalloc = [ "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: FLAGS: -o, --only Only analyze items matching this path -h, --help Prints help information - --memory-usage Collect memory usage statistics (requires `--features jemalloc`) + --memory-usage Collect memory usage statistics --randomize Randomize order in which crates, modules, and items are processed --parallel Run type inference in parallel --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis @@ -221,7 +221,7 @@ USAGE: FLAGS: -h, --help Prints help information - --memory-usage Collect memory usage statistics (requires `--features jemalloc`) + --memory-usage Collect memory usage statistics --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis --with-proc-macro Use ra-proc-macro-srv for proc-macro expanding -v, --verbose -- cgit v1.2.3