]> git.lizzy.rs Git - rust.git/commitdiff
Remove support for jemalloc
authorAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 22 Jul 2020 11:40:45 +0000 (13:40 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 22 Jul 2020 11:40:45 +0000 (13:40 +0200)
We only used it for measuring memory usage, but now we can use glibc's
allocator for that just fine

Cargo.lock
crates/ra_prof/Cargo.toml
crates/ra_prof/src/lib.rs
crates/ra_prof/src/memory_usage.rs
crates/rust-analyzer/Cargo.toml
crates/rust-analyzer/src/bin/args.rs
docs/dev/README.md
xtask/src/dist.rs
xtask/src/install.rs
xtask/src/main.rs

index 4a8271f09dad3c96c083236f914d9cf76fa6c492..62fd9bfb6e45932404d7a19064779f1f778dd6d9 100644 (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",
index 2e60858f1c9ee3511bbc9af4dcd3fd90a50126e7..84d895317168d3859e669ddf951ec418f1c34514 100644 (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" ]
index b54531b4e13150d1804189b80f2d8e305cc08d3d..a5b408a1d1716f7607401112ba57b5b82592b43f 100644 (file)
     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;
index b1858b06f902900588ab86ca5a90eadbf7b7858e..ee79ec3eee25af08f590edd95cb35ee412400db2 100644 (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) }
index 5eb2d0bb701ed29582d942248d7a143b38e975a9..215eeb2f6c7dd65cc39784d00b55a75abe69b99d 100644 (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" ]
index 3210416ee175376d33a69d6c81d98339b9a66d20..741a2a951c7eb02f6af9fa6cb3c916ed75682435 100644 (file)
@@ -166,7 +166,7 @@ pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
 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 @@ pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
 
 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
index 3af01cd6b7dde24effc06712b7d4d551eda86e3a..2bb2f75bdf2c8ee875902e0d8a95739c7cfec04e 100644 (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.
 
index b8f68027c04311f987712cca31d4f5856abeafe7..c198c0907707dcc1c66fc6f95c5c75cf6a77180e 100644 (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")?;
index a0dc0c9c2105469c88cfcc1e19e545fc320a77bf..b25a6e301fcb87f807af78dd621ecedaa4b8c1f9 100644 (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);
index 399ff72049b77b80add6e47d501e1507ae146e34..53d3ce3e72b086c2a88cdaf73ce78350da074261 100644 (file)
@@ -45,7 +45,6 @@ fn main() -> Result<()> {
 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 @@ fn main() -> Result<()> {
                 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()?;