diff options
author | Aleksey Kladov <[email protected]> | 2019-01-28 12:52:21 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-28 12:52:21 +0000 |
commit | 2ee08098a6315aaab07f14c67db024ee0e95af3e (patch) | |
tree | daa75c52c641577945c44b0d4f9838772341988f | |
parent | 3432c4366f578b4f0a9a6e0384292d72e43ebf03 (diff) |
opt-in jemalloc
-rw-r--r-- | ARCHITECTURE.md | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/Cargo.toml | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 9 | ||||
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 3 |
5 files changed, 23 insertions, 3 deletions
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 2c0da0665..cb8f01f78 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md | |||
@@ -184,7 +184,10 @@ To see logs from the language server, set `RUST_LOG=info` env variable. To see | |||
184 | all communication between the server and the client, use | 184 | all communication between the server and the client, use |
185 | `RUST_LOG=gen_lsp_server=debug` (this will print quite a bit of stuff). | 185 | `RUST_LOG=gen_lsp_server=debug` (this will print quite a bit of stuff). |
186 | 186 | ||
187 | There's `Status of rust-analyzer` command which prints common high-level debug info. | 187 | There's `rust-analyzer: status` command which prints common high-level debug |
188 | info. In particular, it prints info about memory usage of various data | ||
189 | structures, and, if compiled with jemalloc support (`cargo install --features | ||
190 | jemalloc`), the summary statistic about the heap. | ||
188 | 191 | ||
189 | To run tests, just `cargo test`. | 192 | To run tests, just `cargo test`. |
190 | 193 | ||
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index ad9dd2088..908899129 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml | |||
@@ -14,8 +14,9 @@ fst = "0.3.1" | |||
14 | rustc-hash = "1.0" | 14 | rustc-hash = "1.0" |
15 | parking_lot = "0.7.0" | 15 | parking_lot = "0.7.0" |
16 | unicase = "2.2.0" | 16 | unicase = "2.2.0" |
17 | jemallocator = "0.1.9" | 17 | |
18 | jemalloc-ctl = "0.2.0" | 18 | jemallocator = { version = "0.1.9", optional = true } |
19 | jemalloc-ctl = { version = "0.2.0", optional = true } | ||
19 | 20 | ||
20 | ra_syntax = { path = "../ra_syntax" } | 21 | ra_syntax = { path = "../ra_syntax" } |
21 | ra_ide_api_light = { path = "../ra_ide_api_light" } | 22 | ra_ide_api_light = { path = "../ra_ide_api_light" } |
@@ -26,3 +27,6 @@ test_utils = { path = "../test_utils" } | |||
26 | 27 | ||
27 | [dev-dependencies] | 28 | [dev-dependencies] |
28 | insta = "0.5.1" | 29 | insta = "0.5.1" |
30 | |||
31 | [features] | ||
32 | jemalloc = [ "jemallocator", "jemalloc-ctl" ] | ||
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index dc531e068..51947e4cc 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -61,6 +61,7 @@ pub use ra_db::{ | |||
61 | 61 | ||
62 | // We use jemalloc mainly to get heap usage statistics, actual performance | 62 | // We use jemalloc mainly to get heap usage statistics, actual performance |
63 | // differnece is not measures. | 63 | // differnece is not measures. |
64 | #[cfg(feature = "jemalloc")] | ||
64 | #[global_allocator] | 65 | #[global_allocator] |
65 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | 66 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; |
66 | 67 | ||
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index c3e5745d5..bd355dd78 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -133,6 +133,7 @@ struct MemoryStats { | |||
133 | } | 133 | } |
134 | 134 | ||
135 | impl MemoryStats { | 135 | impl MemoryStats { |
136 | #[cfg(feature = "jemalloc")] | ||
136 | fn current() -> MemoryStats { | 137 | fn current() -> MemoryStats { |
137 | jemalloc_ctl::epoch().unwrap(); | 138 | jemalloc_ctl::epoch().unwrap(); |
138 | MemoryStats { | 139 | MemoryStats { |
@@ -140,6 +141,14 @@ impl MemoryStats { | |||
140 | resident: Bytes(jemalloc_ctl::stats::resident().unwrap()), | 141 | resident: Bytes(jemalloc_ctl::stats::resident().unwrap()), |
141 | } | 142 | } |
142 | } | 143 | } |
144 | |||
145 | #[cfg(not(feature = "jemalloc"))] | ||
146 | fn current() -> MemoryStats { | ||
147 | MemoryStats { | ||
148 | allocated: Bytes(0), | ||
149 | resident: Bytes(0), | ||
150 | } | ||
151 | } | ||
143 | } | 152 | } |
144 | 153 | ||
145 | impl fmt::Display for MemoryStats { | 154 | impl fmt::Display for MemoryStats { |
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 160d2f672..bb92747f2 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -34,3 +34,6 @@ ra_vfs = { path = "../ra_vfs" } | |||
34 | [dev-dependencies] | 34 | [dev-dependencies] |
35 | tempfile = "3" | 35 | tempfile = "3" |
36 | test_utils = { path = "../test_utils" } | 36 | test_utils = { path = "../test_utils" } |
37 | |||
38 | [features] | ||
39 | jemalloc = [ "ra_ide_api/jemalloc" ] | ||