aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock39
-rw-r--r--crates/ra_ide_api/Cargo.toml2
-rw-r--r--crates/ra_ide_api/src/lib.rs5
-rw-r--r--crates/ra_ide_api/src/status.rs28
4 files changed, 73 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index cbd4461c9..c8d29e3b7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -381,6 +381,11 @@ version = "1.0.6"
381source = "registry+https://github.com/rust-lang/crates.io-index" 381source = "registry+https://github.com/rust-lang/crates.io-index"
382 382
383[[package]] 383[[package]]
384name = "fs_extra"
385version = "1.1.0"
386source = "registry+https://github.com/rust-lang/crates.io-index"
387
388[[package]]
384name = "fsevent" 389name = "fsevent"
385version = "0.2.17" 390version = "0.2.17"
386source = "registry+https://github.com/rust-lang/crates.io-index" 391source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -552,6 +557,34 @@ version = "0.4.3"
552source = "registry+https://github.com/rust-lang/crates.io-index" 557source = "registry+https://github.com/rust-lang/crates.io-index"
553 558
554[[package]] 559[[package]]
560name = "jemalloc-ctl"
561version = "0.2.0"
562source = "registry+https://github.com/rust-lang/crates.io-index"
563dependencies = [
564 "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
565 "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
566]
567
568[[package]]
569name = "jemalloc-sys"
570version = "0.1.8"
571source = "registry+https://github.com/rust-lang/crates.io-index"
572dependencies = [
573 "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
574 "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
575 "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
576]
577
578[[package]]
579name = "jemallocator"
580version = "0.1.9"
581source = "registry+https://github.com/rust-lang/crates.io-index"
582dependencies = [
583 "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
584 "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
585]
586
587[[package]]
555name = "join_to_string" 588name = "join_to_string"
556version = "0.1.3" 589version = "0.1.3"
557source = "registry+https://github.com/rust-lang/crates.io-index" 590source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -920,6 +953,8 @@ dependencies = [
920 "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 953 "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
921 "insta 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 954 "insta 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
922 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 955 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
956 "jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
957 "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
923 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 958 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
924 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 959 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
925 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 960 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1866,6 +1901,7 @@ dependencies = [
1866"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646" 1901"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
1867"checksum flexi_logger 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bbd731387787f54fa333fa426e173fe42ea3d1123636b2b27ad802025fc5d182" 1902"checksum flexi_logger 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bbd731387787f54fa333fa426e173fe42ea3d1123636b2b27ad802025fc5d182"
1868"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 1903"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
1904"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
1869"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05" 1905"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05"
1870"checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874" 1906"checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874"
1871"checksum fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "db72126ca7dff566cdbbdd54af44668c544897d9d3862b198141f176f1238bdf" 1907"checksum fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "db72126ca7dff566cdbbdd54af44668c544897d9d3862b198141f176f1238bdf"
@@ -1885,6 +1921,9 @@ dependencies = [
1885"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" 1921"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
1886"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" 1922"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
1887"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" 1923"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
1924"checksum jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e93b0f37e7d735c6b610176d5b1bde8e1621ff3f6f7ac23cdfa4e7f7d0111b5"
1925"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
1926"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3"
1888"checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f" 1927"checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f"
1889"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 1928"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
1890"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" 1929"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index 79e473463..ad9dd2088 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -14,6 +14,8 @@ fst = "0.3.1"
14rustc-hash = "1.0" 14rustc-hash = "1.0"
15parking_lot = "0.7.0" 15parking_lot = "0.7.0"
16unicase = "2.2.0" 16unicase = "2.2.0"
17jemallocator = "0.1.9"
18jemalloc-ctl = "0.2.0"
17 19
18ra_syntax = { path = "../ra_syntax" } 20ra_syntax = { path = "../ra_syntax" }
19ra_ide_api_light = { path = "../ra_ide_api_light" } 21ra_ide_api_light = { path = "../ra_ide_api_light" }
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index a7caac02d..dc531e068 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -59,6 +59,11 @@ pub use ra_db::{
59 Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId 59 Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId
60}; 60};
61 61
62// We use jemalloc mainly to get heap usage statistics, actual performance
63// differnece is not measures.
64#[global_allocator]
65static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
66
62pub type Cancelable<T> = Result<T, Canceled>; 67pub type Cancelable<T> = Result<T, Canceled>;
63 68
64#[derive(Default)] 69#[derive(Default)]
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs
index 0dde30ae0..686ab97d2 100644
--- a/crates/ra_ide_api/src/status.rs
+++ b/crates/ra_ide_api/src/status.rs
@@ -30,11 +30,12 @@ pub(crate) fn status(db: &RootDatabase) -> String {
30 interner.len() 30 interner.len()
31 }; 31 };
32 format!( 32 format!(
33 "{}\n{}\n{}\nn_defs {}\nGC {:?} seconds ago", 33 "{}\n{}\n{}\nn_defs {}\n\njemalloc: {}\nGC {:?} seconds ago",
34 files_stats, 34 files_stats,
35 symbols_stats, 35 symbols_stats,
36 syntax_tree_stats, 36 syntax_tree_stats,
37 n_defs, 37 n_defs,
38 MemoryStats::current(),
38 db.last_gc.elapsed().as_secs(), 39 db.last_gc.elapsed().as_secs(),
39 ) 40 )
40} 41}
@@ -126,6 +127,31 @@ impl FromIterator<TableEntry<SourceRootId, Arc<SymbolIndex>>> for LibrarySymbols
126 } 127 }
127} 128}
128 129
130struct MemoryStats {
131 allocated: Bytes,
132 resident: Bytes,
133}
134
135impl MemoryStats {
136 fn current() -> MemoryStats {
137 jemalloc_ctl::epoch().unwrap();
138 MemoryStats {
139 allocated: Bytes(jemalloc_ctl::stats::allocated().unwrap()),
140 resident: Bytes(jemalloc_ctl::stats::resident().unwrap()),
141 }
142 }
143}
144
145impl fmt::Display for MemoryStats {
146 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
147 write!(
148 fmt,
149 "{} allocated {} resident",
150 self.allocated, self.resident,
151 )
152 }
153}
154
129#[derive(Default)] 155#[derive(Default)]
130struct Bytes(usize); 156struct Bytes(usize);
131 157