Skip to content

Commit deed44a

Browse files
committed
Remove support for jemalloc
We only used it for measuring memory usage, but now we can use glibc's allocator for that just fine
1 parent 26932e0 commit deed44a

File tree

10 files changed

+7
-109
lines changed

10 files changed

+7
-109
lines changed

Cargo.lock

Lines changed: 0 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_prof/Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,10 @@ mimalloc = { version = "0.1.19", default-features = false, optional = true }
1717
cfg-if = "0.1.10"
1818
libc = "0.2.73"
1919

20-
[target.'cfg(not(target_env = "msvc"))'.dependencies]
21-
jemallocator = { version = "0.3.2", optional = true }
22-
jemalloc-ctl = { version = "0.3.3", optional = true }
23-
2420
[features]
25-
jemalloc = [ "jemallocator", "jemalloc-ctl" ]
2621
cpu_profiler = []
2722

2823
# Uncomment to enable for the whole crate graph
2924
# default = [ "backtrace" ]
30-
# default = [ "jemalloc" ]
3125
# default = [ "mimalloc" ]
3226
# default = [ "cpu_profiler" ]

crates/ra_prof/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ pub use crate::{
1313
memory_usage::{Bytes, MemoryUsage},
1414
};
1515

16-
// We use jemalloc mainly to get heap usage statistics, actual performance
17-
// difference is not measures.
18-
#[cfg(all(feature = "jemalloc", not(target_env = "msvc")))]
19-
#[global_allocator]
20-
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
21-
2216
#[cfg(all(feature = "mimalloc"))]
2317
#[global_allocator]
2418
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

crates/ra_prof/src/memory_usage.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! FIXME: write short doc here
2+
use std::fmt;
23

34
use cfg_if::cfg_if;
4-
use std::fmt;
55

66
pub struct MemoryUsage {
77
pub allocated: Bytes,
@@ -11,13 +11,7 @@ pub struct MemoryUsage {
1111
impl MemoryUsage {
1212
pub fn current() -> MemoryUsage {
1313
cfg_if! {
14-
if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] {
15-
jemalloc_ctl::epoch::advance().unwrap();
16-
MemoryUsage {
17-
allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap()),
18-
resident: Bytes(jemalloc_ctl::stats::resident::read().unwrap()),
19-
}
20-
} else if #[cfg(target_os = "linux")] {
14+
if #[cfg(target_os = "linux")] {
2115
// Note: This is incredibly slow.
2216
let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize;
2317
MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) }

crates/rust-analyzer/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,4 @@ mbe = { path = "../ra_mbe", package = "ra_mbe" }
6464
tt = { path = "../ra_tt", package = "ra_tt" }
6565

6666
[features]
67-
jemalloc = [ "ra_prof/jemalloc" ]
6867
mimalloc = [ "ra_prof/mimalloc" ]

crates/rust-analyzer/src/bin/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ USAGE:
166166
FLAGS:
167167
-o, --only Only analyze items matching this path
168168
-h, --help Prints help information
169-
--memory-usage Collect memory usage statistics (requires `--features jemalloc`)
169+
--memory-usage Collect memory usage statistics
170170
--randomize Randomize order in which crates, modules, and items are processed
171171
--parallel Run type inference in parallel
172172
--load-output-dirs Load OUT_DIR values by running `cargo check` before analysis
@@ -221,7 +221,7 @@ USAGE:
221221
222222
FLAGS:
223223
-h, --help Prints help information
224-
--memory-usage Collect memory usage statistics (requires `--features jemalloc`)
224+
--memory-usage Collect memory usage statistics
225225
--load-output-dirs Load OUT_DIR values by running `cargo check` before analysis
226226
--with-proc-macro Use ra-proc-macro-srv for proc-macro expanding
227227
-v, --verbose

docs/dev/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,7 @@ To log all communication between the server and the client, there are two choice
397397

398398
There are also two VS Code commands which might be of interest:
399399

400-
* `Rust Analyzer: Status` shows some memory-usage statistics. To take full
401-
advantage of it, you need to compile rust-analyzer with jemalloc support:
402-
```
403-
$ cargo install --path crates/rust-analyzer --force --features jemalloc
404-
```
405-
406-
There's an alias for this: `cargo xtask install --server --jemalloc`.
400+
* `Rust Analyzer: Status` shows some memory-usage statistics.
407401

408402
* `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection.
409403

xtask/src/dist.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ fn dist_server() -> Result<()> {
5757
env::set_var("CC", "clang");
5858
run!(
5959
"cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release"
60-
// We'd want to add, but that requires setting the right linker somehow
61-
// --features=jemalloc
6260
)?;
6361
} else {
6462
run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?;

xtask/src/install.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub struct ServerOpt {
2424

2525
pub enum Malloc {
2626
System,
27-
Jemalloc,
2827
Mimalloc,
2928
}
3029

@@ -138,7 +137,6 @@ fn install_server(opts: ServerOpt) -> Result<()> {
138137

139138
let malloc_feature = match opts.malloc {
140139
Malloc::System => "",
141-
Malloc::Jemalloc => "--features jemalloc",
142140
Malloc::Mimalloc => "--features mimalloc",
143141
};
144142
let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", malloc_feature);

xtask/src/main.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ USAGE:
4545
FLAGS:
4646
--client-code Install only VS Code plugin
4747
--server Install only the language server
48-
--jemalloc Use jemalloc for server
4948
--mimalloc Use mimalloc for server
5049
-h, --help Prints help information
5150
"
@@ -62,15 +61,8 @@ FLAGS:
6261
return Ok(());
6362
}
6463

65-
let malloc = match (args.contains("--jemalloc"), args.contains("--mimalloc")) {
66-
(false, false) => Malloc::System,
67-
(true, false) => Malloc::Jemalloc,
68-
(false, true) => Malloc::Mimalloc,
69-
(true, true) => {
70-
eprintln!("error: Cannot use both `--jemalloc` and `--mimalloc`");
71-
return Ok(());
72-
}
73-
};
64+
let malloc =
65+
if args.contains("--mimalloc") { Malloc::Mimalloc } else { Malloc::System };
7466

7567
args.finish()?;
7668

0 commit comments

Comments
 (0)