]> git.lizzy.rs Git - rust.git/commitdiff
opt-in jemalloc
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 28 Jan 2019 12:52:21 +0000 (15:52 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 28 Jan 2019 12:52:21 +0000 (15:52 +0300)
ARCHITECTURE.md
crates/ra_ide_api/Cargo.toml
crates/ra_ide_api/src/lib.rs
crates/ra_ide_api/src/status.rs
crates/ra_lsp_server/Cargo.toml

index 2c0da066511179e7c98532066cc97c73f4df470e..cb8f01f78887ff31041a638bf8d520569a931b07 100644 (file)
@@ -184,7 +184,10 @@ To see logs from the language server, set `RUST_LOG=info` env variable. To see
 all communication between the server and the client, use
 `RUST_LOG=gen_lsp_server=debug` (this will print quite a bit of stuff).
 
-There's `Status of rust-analyzer` command which prints common high-level debug info.
+There's `rust-analyzer: status` command which prints common high-level debug
+info. In particular, it prints info about memory usage of various data
+structures, and, if compiled with jemalloc support (`cargo install --features
+jemalloc`), the summary statistic about the heap.
 
 To run tests, just `cargo test`.
 
index ad9dd20882f045586d0ae01eccc8c74970e366b7..908899129fa45df47e2cbbc62ffb62bd20c9459b 100644 (file)
@@ -14,8 +14,9 @@ fst = "0.3.1"
 rustc-hash = "1.0"
 parking_lot = "0.7.0"
 unicase = "2.2.0"
-jemallocator = "0.1.9"
-jemalloc-ctl = "0.2.0"
+
+jemallocator = { version = "0.1.9", optional = true }
+jemalloc-ctl = { version = "0.2.0", optional = true }
 
 ra_syntax = { path = "../ra_syntax" }
 ra_ide_api_light = { path = "../ra_ide_api_light" }
@@ -26,3 +27,6 @@ test_utils = { path = "../test_utils" }
 
 [dev-dependencies]
 insta = "0.5.1"
+
+[features]
+jemalloc = [ "jemallocator", "jemalloc-ctl" ]
index dc531e068d248be3ae19a803217aef606e6fb382..51947e4ccd2faeac21455ec72f1af7c396012ef1 100644 (file)
@@ -61,6 +61,7 @@
 
 // We use jemalloc mainly to get heap usage statistics, actual performance
 // differnece is not measures.
+#[cfg(feature = "jemalloc")]
 #[global_allocator]
 static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
 
index c3e5745d5e15bae98889ddc6960caa51d08ef925..bd355dd781dad0346c7f17d530f8e1cc0dc3c037 100644 (file)
@@ -133,6 +133,7 @@ struct MemoryStats {
 }
 
 impl MemoryStats {
+    #[cfg(feature = "jemalloc")]
     fn current() -> MemoryStats {
         jemalloc_ctl::epoch().unwrap();
         MemoryStats {
@@ -140,6 +141,14 @@ fn current() -> MemoryStats {
             resident: Bytes(jemalloc_ctl::stats::resident().unwrap()),
         }
     }
+
+    #[cfg(not(feature = "jemalloc"))]
+    fn current() -> MemoryStats {
+        MemoryStats {
+            allocated: Bytes(0),
+            resident: Bytes(0),
+        }
+    }
 }
 
 impl fmt::Display for MemoryStats {
index 160d2f672a88ecc2fb7a217665a33c97c3058678..bb92747f2f0815aaed1b7152dfa87025ea4c3d1c 100644 (file)
@@ -34,3 +34,6 @@ ra_vfs = { path = "../ra_vfs" }
 [dev-dependencies]
 tempfile = "3"
 test_utils = { path = "../test_utils" }
+
+[features]
+jemalloc = [ "ra_ide_api/jemalloc" ]