diff options
-rw-r--r-- | Cargo.lock | 67 | ||||
-rw-r--r-- | crates/ra_prof/Cargo.toml | 8 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_prof/src/memory_usage.rs | 10 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 5 | ||||
-rw-r--r-- | crates/rust-analyzer/src/bin/args.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 4 | ||||
-rw-r--r-- | docs/dev/README.md | 8 | ||||
-rw-r--r-- | xtask/src/dist.rs | 2 | ||||
-rw-r--r-- | xtask/src/install.rs | 2 | ||||
-rw-r--r-- | xtask/src/main.rs | 12 |
11 files changed, 13 insertions, 119 deletions
diff --git a/Cargo.lock b/Cargo.lock index 4a8271f09..280d97432 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -360,12 +360,6 @@ dependencies = [ | |||
360 | ] | 360 | ] |
361 | 361 | ||
362 | [[package]] | 362 | [[package]] |
363 | name = "fs_extra" | ||
364 | version = "1.1.0" | ||
365 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
366 | checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" | ||
367 | |||
368 | [[package]] | ||
369 | name = "fsevent" | 363 | name = "fsevent" |
370 | version = "2.0.2" | 364 | version = "2.0.2" |
371 | source = "registry+https://github.com/rust-lang/crates.io-index" | 365 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -542,38 +536,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
542 | checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" | 536 | checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" |
543 | 537 | ||
544 | [[package]] | 538 | [[package]] |
545 | name = "jemalloc-ctl" | ||
546 | version = "0.3.3" | ||
547 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
548 | checksum = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7" | ||
549 | dependencies = [ | ||
550 | "jemalloc-sys", | ||
551 | "libc", | ||
552 | "paste", | ||
553 | ] | ||
554 | |||
555 | [[package]] | ||
556 | name = "jemalloc-sys" | ||
557 | version = "0.3.2" | ||
558 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
559 | checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" | ||
560 | dependencies = [ | ||
561 | "cc", | ||
562 | "fs_extra", | ||
563 | "libc", | ||
564 | ] | ||
565 | |||
566 | [[package]] | ||
567 | name = "jemallocator" | ||
568 | version = "0.3.2" | ||
569 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
570 | checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" | ||
571 | dependencies = [ | ||
572 | "jemalloc-sys", | ||
573 | "libc", | ||
574 | ] | ||
575 | |||
576 | [[package]] | ||
577 | name = "jod-thread" | 539 | name = "jod-thread" |
578 | version = "0.1.2" | 540 | version = "0.1.2" |
579 | source = "registry+https://github.com/rust-lang/crates.io-index" | 541 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -875,25 +837,6 @@ dependencies = [ | |||
875 | ] | 837 | ] |
876 | 838 | ||
877 | [[package]] | 839 | [[package]] |
878 | name = "paste" | ||
879 | version = "0.1.18" | ||
880 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
881 | checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" | ||
882 | dependencies = [ | ||
883 | "paste-impl", | ||
884 | "proc-macro-hack", | ||
885 | ] | ||
886 | |||
887 | [[package]] | ||
888 | name = "paste-impl" | ||
889 | version = "0.1.18" | ||
890 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
891 | checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" | ||
892 | dependencies = [ | ||
893 | "proc-macro-hack", | ||
894 | ] | ||
895 | |||
896 | [[package]] | ||
897 | name = "paths" | 840 | name = "paths" |
898 | version = "0.1.0" | 841 | version = "0.1.0" |
899 | 842 | ||
@@ -932,12 +875,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
932 | checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" | 875 | checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" |
933 | 876 | ||
934 | [[package]] | 877 | [[package]] |
935 | name = "proc-macro-hack" | ||
936 | version = "0.5.16" | ||
937 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
938 | checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" | ||
939 | |||
940 | [[package]] | ||
941 | name = "proc-macro2" | 878 | name = "proc-macro2" |
942 | version = "1.0.19" | 879 | version = "1.0.19" |
943 | source = "registry+https://github.com/rust-lang/crates.io-index" | 880 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1199,10 +1136,7 @@ version = "0.1.0" | |||
1199 | dependencies = [ | 1136 | dependencies = [ |
1200 | "backtrace", | 1137 | "backtrace", |
1201 | "cfg-if", | 1138 | "cfg-if", |
1202 | "jemalloc-ctl", | ||
1203 | "jemallocator", | ||
1204 | "libc", | 1139 | "libc", |
1205 | "mimalloc", | ||
1206 | "once_cell", | 1140 | "once_cell", |
1207 | "ra_arena", | 1141 | "ra_arena", |
1208 | ] | 1142 | ] |
@@ -1427,6 +1361,7 @@ dependencies = [ | |||
1427 | "log", | 1361 | "log", |
1428 | "lsp-server", | 1362 | "lsp-server", |
1429 | "lsp-types", | 1363 | "lsp-types", |
1364 | "mimalloc", | ||
1430 | "parking_lot", | 1365 | "parking_lot", |
1431 | "pico-args", | 1366 | "pico-args", |
1432 | "ra_cfg", | 1367 | "ra_cfg", |
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index 2e60858f1..6c214501e 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml | |||
@@ -13,20 +13,12 @@ doctest = false | |||
13 | ra_arena = { path = "../ra_arena" } | 13 | ra_arena = { path = "../ra_arena" } |
14 | once_cell = "1.3.1" | 14 | once_cell = "1.3.1" |
15 | backtrace = { version = "0.3.44", optional = true } | 15 | backtrace = { version = "0.3.44", optional = true } |
16 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | ||
17 | cfg-if = "0.1.10" | 16 | cfg-if = "0.1.10" |
18 | libc = "0.2.73" | 17 | libc = "0.2.73" |
19 | 18 | ||
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 | |||
24 | [features] | 19 | [features] |
25 | jemalloc = [ "jemallocator", "jemalloc-ctl" ] | ||
26 | cpu_profiler = [] | 20 | cpu_profiler = [] |
27 | 21 | ||
28 | # Uncomment to enable for the whole crate graph | 22 | # Uncomment to enable for the whole crate graph |
29 | # default = [ "backtrace" ] | 23 | # default = [ "backtrace" ] |
30 | # default = [ "jemalloc" ] | ||
31 | # default = [ "mimalloc" ] | ||
32 | # default = [ "cpu_profiler" ] | 24 | # default = [ "cpu_profiler" ] |
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index b54531b4e..ba5609703 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -13,16 +13,6 @@ pub use crate::{ | |||
13 | memory_usage::{Bytes, MemoryUsage}, | 13 | memory_usage::{Bytes, MemoryUsage}, |
14 | }; | 14 | }; |
15 | 15 | ||
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 | |||
22 | #[cfg(all(feature = "mimalloc"))] | ||
23 | #[global_allocator] | ||
24 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | ||
25 | |||
26 | /// Prints backtrace to stderr, useful for debugging. | 16 | /// Prints backtrace to stderr, useful for debugging. |
27 | #[cfg(feature = "backtrace")] | 17 | #[cfg(feature = "backtrace")] |
28 | pub fn print_backtrace() { | 18 | pub fn print_backtrace() { |
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs index b1858b06f..ee79ec3ee 100644 --- a/crates/ra_prof/src/memory_usage.rs +++ b/crates/ra_prof/src/memory_usage.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | use std::fmt; | ||
2 | 3 | ||
3 | use cfg_if::cfg_if; | 4 | use cfg_if::cfg_if; |
4 | use std::fmt; | ||
5 | 5 | ||
6 | pub struct MemoryUsage { | 6 | pub struct MemoryUsage { |
7 | pub allocated: Bytes, | 7 | pub allocated: Bytes, |
@@ -11,13 +11,7 @@ pub struct MemoryUsage { | |||
11 | impl MemoryUsage { | 11 | impl MemoryUsage { |
12 | pub fn current() -> MemoryUsage { | 12 | pub fn current() -> MemoryUsage { |
13 | cfg_if! { | 13 | cfg_if! { |
14 | if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { | 14 | if #[cfg(target_os = "linux")] { |
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")] { | ||
21 | // Note: This is incredibly slow. | 15 | // Note: This is incredibly slow. |
22 | let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize; | 16 | let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize; |
23 | MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) } | 17 | MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) } |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 5eb2d0bb7..023c104d1 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -29,6 +29,7 @@ serde = { version = "1.0.106", features = ["derive"] } | |||
29 | serde_json = "1.0.48" | 29 | serde_json = "1.0.48" |
30 | threadpool = "1.7.1" | 30 | threadpool = "1.7.1" |
31 | rayon = "1.3.1" | 31 | rayon = "1.3.1" |
32 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | ||
32 | 33 | ||
33 | stdx = { path = "../stdx" } | 34 | stdx = { path = "../stdx" } |
34 | 35 | ||
@@ -62,7 +63,3 @@ expect = { path = "../expect" } | |||
62 | test_utils = { path = "../test_utils" } | 63 | test_utils = { path = "../test_utils" } |
63 | mbe = { path = "../ra_mbe", package = "ra_mbe" } | 64 | mbe = { path = "../ra_mbe", package = "ra_mbe" } |
64 | tt = { path = "../ra_tt", package = "ra_tt" } | 65 | tt = { path = "../ra_tt", package = "ra_tt" } |
65 | |||
66 | [features] | ||
67 | jemalloc = [ "ra_prof/jemalloc" ] | ||
68 | mimalloc = [ "ra_prof/mimalloc" ] | ||
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs index 3210416ee..741a2a951 100644 --- a/crates/rust-analyzer/src/bin/args.rs +++ b/crates/rust-analyzer/src/bin/args.rs | |||
@@ -166,7 +166,7 @@ USAGE: | |||
166 | FLAGS: | 166 | FLAGS: |
167 | -o, --only Only analyze items matching this path | 167 | -o, --only Only analyze items matching this path |
168 | -h, --help Prints help information | 168 | -h, --help Prints help information |
169 | --memory-usage Collect memory usage statistics (requires `--features jemalloc`) | 169 | --memory-usage Collect memory usage statistics |
170 | --randomize Randomize order in which crates, modules, and items are processed | 170 | --randomize Randomize order in which crates, modules, and items are processed |
171 | --parallel Run type inference in parallel | 171 | --parallel Run type inference in parallel |
172 | --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis | 172 | --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis |
@@ -221,7 +221,7 @@ USAGE: | |||
221 | 221 | ||
222 | FLAGS: | 222 | FLAGS: |
223 | -h, --help Prints help information | 223 | -h, --help Prints help information |
224 | --memory-usage Collect memory usage statistics (requires `--features jemalloc`) | 224 | --memory-usage Collect memory usage statistics |
225 | --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis | 225 | --load-output-dirs Load OUT_DIR values by running `cargo check` before analysis |
226 | --with-proc-macro Use ra-proc-macro-srv for proc-macro expanding | 226 | --with-proc-macro Use ra-proc-macro-srv for proc-macro expanding |
227 | -v, --verbose | 227 | -v, --verbose |
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 408892eab..a473c9165 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs | |||
@@ -16,6 +16,10 @@ use vfs::AbsPathBuf; | |||
16 | 16 | ||
17 | use crate::args::HelpPrinted; | 17 | use crate::args::HelpPrinted; |
18 | 18 | ||
19 | #[cfg(all(feature = "mimalloc"))] | ||
20 | #[global_allocator] | ||
21 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | ||
22 | |||
19 | fn main() -> Result<()> { | 23 | fn main() -> Result<()> { |
20 | setup_logging()?; | 24 | setup_logging()?; |
21 | let args = match args::Args::parse()? { | 25 | let args = match args::Args::parse()? { |
diff --git a/docs/dev/README.md b/docs/dev/README.md index 3af01cd6b..2bb2f75bd 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -397,13 +397,7 @@ To log all communication between the server and the client, there are two choice | |||
397 | 397 | ||
398 | There are also two VS Code commands which might be of interest: | 398 | There are also two VS Code commands which might be of interest: |
399 | 399 | ||
400 | * `Rust Analyzer: Status` shows some memory-usage statistics. To take full | 400 | * `Rust Analyzer: Status` shows some memory-usage statistics. |
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`. | ||
407 | 401 | ||
408 | * `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection. | 402 | * `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection. |
409 | 403 | ||
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index b8f68027c..c198c0907 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs | |||
@@ -57,8 +57,6 @@ fn dist_server() -> Result<()> { | |||
57 | env::set_var("CC", "clang"); | 57 | env::set_var("CC", "clang"); |
58 | run!( | 58 | run!( |
59 | "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release" | 59 | "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 | ||
62 | )?; | 60 | )?; |
63 | } else { | 61 | } else { |
64 | run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?; | 62 | run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?; |
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index a0dc0c9c2..b25a6e301 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -24,7 +24,6 @@ pub struct ServerOpt { | |||
24 | 24 | ||
25 | pub enum Malloc { | 25 | pub enum Malloc { |
26 | System, | 26 | System, |
27 | Jemalloc, | ||
28 | Mimalloc, | 27 | Mimalloc, |
29 | } | 28 | } |
30 | 29 | ||
@@ -138,7 +137,6 @@ fn install_server(opts: ServerOpt) -> Result<()> { | |||
138 | 137 | ||
139 | let malloc_feature = match opts.malloc { | 138 | let malloc_feature = match opts.malloc { |
140 | Malloc::System => "", | 139 | Malloc::System => "", |
141 | Malloc::Jemalloc => "--features jemalloc", | ||
142 | Malloc::Mimalloc => "--features mimalloc", | 140 | Malloc::Mimalloc => "--features mimalloc", |
143 | }; | 141 | }; |
144 | let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", malloc_feature); | 142 | let res = run!("cargo install --path crates/rust-analyzer --locked --force {}", malloc_feature); |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 399ff7204..53d3ce3e7 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -45,7 +45,6 @@ USAGE: | |||
45 | FLAGS: | 45 | FLAGS: |
46 | --client-code Install only VS Code plugin | 46 | --client-code Install only VS Code plugin |
47 | --server Install only the language server | 47 | --server Install only the language server |
48 | --jemalloc Use jemalloc for server | ||
49 | --mimalloc Use mimalloc for server | 48 | --mimalloc Use mimalloc for server |
50 | -h, --help Prints help information | 49 | -h, --help Prints help information |
51 | " | 50 | " |
@@ -62,15 +61,8 @@ FLAGS: | |||
62 | return Ok(()); | 61 | return Ok(()); |
63 | } | 62 | } |
64 | 63 | ||
65 | let malloc = match (args.contains("--jemalloc"), args.contains("--mimalloc")) { | 64 | let malloc = |
66 | (false, false) => Malloc::System, | 65 | if args.contains("--mimalloc") { Malloc::Mimalloc } else { 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 | }; | ||
74 | 66 | ||
75 | args.finish()?; | 67 | args.finish()?; |
76 | 68 | ||