Remove support for jemalloc

We only used it for measuring memory usage, but now we can use glibc's
allocator for that just fine
This commit is contained in:
Aleksey Kladov 2020-07-22 13:40:45 +02:00
parent 26932e0060
commit deed44a472
10 changed files with 7 additions and 109 deletions

65
Cargo.lock generated
View file

@ -359,12 +359,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "fs_extra"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
[[package]]
name = "fsevent"
version = "2.0.2"
@ -541,38 +535,6 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
name = "jemalloc-ctl"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7"
dependencies = [
"jemalloc-sys",
"libc",
"paste",
]
[[package]]
name = "jemalloc-sys"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45"
dependencies = [
"cc",
"fs_extra",
"libc",
]
[[package]]
name = "jemallocator"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69"
dependencies = [
"jemalloc-sys",
"libc",
]
[[package]]
name = "jod-thread"
version = "0.1.2"
@ -874,25 +836,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "paste"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880"
dependencies = [
"paste-impl",
"proc-macro-hack",
]
[[package]]
name = "paste-impl"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6"
dependencies = [
"proc-macro-hack",
]
[[package]]
name = "paths"
version = "0.1.0"
@ -931,12 +874,6 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
[[package]]
name = "proc-macro-hack"
version = "0.5.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4"
[[package]]
name = "proc-macro2"
version = "1.0.19"
@ -1199,8 +1136,6 @@ version = "0.1.0"
dependencies = [
"backtrace",
"cfg-if",
"jemalloc-ctl",
"jemallocator",
"libc",
"mimalloc",
"once_cell",

View file

@ -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" ]

View file

@ -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;

View file

@ -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) }

View file

@ -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" ]

View file

@ -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

View file

@ -397,13 +397,7 @@ To log all communication between the server and the client, there are two choice
There are also two VS Code commands which might be of interest:
* `Rust Analyzer: Status` shows some memory-usage statistics. To take full
advantage of it, you need to compile rust-analyzer with jemalloc support:
```
$ cargo install --path crates/rust-analyzer --force --features jemalloc
```
There's an alias for this: `cargo xtask install --server --jemalloc`.
* `Rust Analyzer: Status` shows some memory-usage statistics.
* `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection.

View file

@ -57,8 +57,6 @@ fn dist_server() -> Result<()> {
env::set_var("CC", "clang");
run!(
"cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release"
// We'd want to add, but that requires setting the right linker somehow
// --features=jemalloc
)?;
} else {
run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?;

View file

@ -24,7 +24,6 @@ pub struct ServerOpt {
pub enum Malloc {
System,
Jemalloc,
Mimalloc,
}
@ -138,7 +137,6 @@ fn install_server(opts: ServerOpt) -> Result<()> {
let malloc_feature = match opts.malloc {
Malloc::System => "",
Malloc::Jemalloc => "--features jemalloc",
Malloc::Mimalloc => "--features mimalloc",
};
let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", malloc_feature);

View file

@ -45,7 +45,6 @@ USAGE:
FLAGS:
--client-code Install only VS Code plugin
--server Install only the language server
--jemalloc Use jemalloc for server
--mimalloc Use mimalloc for server
-h, --help Prints help information
"
@ -62,15 +61,8 @@ FLAGS:
return Ok(());
}
let malloc = match (args.contains("--jemalloc"), args.contains("--mimalloc")) {
(false, false) => Malloc::System,
(true, false) => Malloc::Jemalloc,
(false, true) => Malloc::Mimalloc,
(true, true) => {
eprintln!("error: Cannot use both `--jemalloc` and `--mimalloc`");
return Ok(());
}
};
let malloc =
if args.contains("--mimalloc") { Malloc::Mimalloc } else { Malloc::System };
args.finish()?;