diff options
author | Sergey Parilin <[email protected]> | 2019-04-02 15:52:04 +0100 |
---|---|---|
committer | Sergey Parilin <[email protected]> | 2019-04-02 15:52:04 +0100 |
commit | 9b73f809596e955216dde24fcf921d6985a1a767 (patch) | |
tree | 016b82dc06800a174c49a0ba88957df9c91d1906 /crates | |
parent | ef02c3c038812897cd96789fa35770e4215d27e8 (diff) |
PR issuse resolved
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_cli/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 10 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 7 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 6 |
8 files changed, 27 insertions, 10 deletions
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 4c666f556..a92a63257 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml | |||
@@ -19,3 +19,4 @@ tools = { path = "../tools" } | |||
19 | ra_batch = { path = "../ra_batch" } | 19 | ra_batch = { path = "../ra_batch" } |
20 | ra_hir = { path = "../ra_hir" } | 20 | ra_hir = { path = "../ra_hir" } |
21 | ra_db = { path = "../ra_db" } | 21 | ra_db = { path = "../ra_db" } |
22 | ra_prof = { path = "../ra_prof" } | ||
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 5285f1f28..c13c7910c 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | mod analysis_stats; | 1 | mod analysis_stats; |
2 | 2 | ||
3 | use std::{fs, io::Read, path::Path, time::Instant}; | 3 | use std::{fs, io::Read, path::Path}; |
4 | 4 | ||
5 | use clap::{App, Arg, SubCommand}; | 5 | use clap::{App, Arg, SubCommand}; |
6 | use join_to_string::join; | 6 | use join_to_string::join; |
@@ -9,6 +9,7 @@ use ra_ide_api_light::file_structure; | |||
9 | use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode}; | 9 | use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode}; |
10 | use tools::collect_tests; | 10 | use tools::collect_tests; |
11 | use flexi_logger::Logger; | 11 | use flexi_logger::Logger; |
12 | use ra_prof::profile; | ||
12 | 13 | ||
13 | type Result<T> = ::std::result::Result<T, failure::Error>; | 14 | type Result<T> = ::std::result::Result<T, failure::Error>; |
14 | 15 | ||
@@ -34,13 +35,11 @@ fn main() -> Result<()> { | |||
34 | .get_matches(); | 35 | .get_matches(); |
35 | match matches.subcommand() { | 36 | match matches.subcommand() { |
36 | ("parse", Some(matches)) => { | 37 | ("parse", Some(matches)) => { |
37 | let start = Instant::now(); | 38 | let _p = profile("parsing"); |
38 | let file = file()?; | 39 | let file = file()?; |
39 | let elapsed = start.elapsed(); | ||
40 | if !matches.is_present("no-dump") { | 40 | if !matches.is_present("no-dump") { |
41 | println!("{}", file.syntax().debug_dump()); | 41 | println!("{}", file.syntax().debug_dump()); |
42 | } | 42 | } |
43 | eprintln!("parsing: {:?}", elapsed); | ||
44 | ::std::mem::forget(file); | 43 | ::std::mem::forget(file); |
45 | } | 44 | } |
46 | ("symbols", _) => { | 45 | ("symbols", _) => { |
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 501308acc..a2858dad9 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml | |||
@@ -19,6 +19,7 @@ ra_db = { path = "../ra_db" } | |||
19 | mbe = { path = "../ra_mbe", package = "ra_mbe" } | 19 | mbe = { path = "../ra_mbe", package = "ra_mbe" } |
20 | tt = { path = "../ra_tt", package = "ra_tt" } | 20 | tt = { path = "../ra_tt", package = "ra_tt" } |
21 | test_utils = { path = "../test_utils" } | 21 | test_utils = { path = "../test_utils" } |
22 | ra_prof = {path = "../ra_prof" } | ||
22 | 23 | ||
23 | [dev-dependencies] | 24 | [dev-dependencies] |
24 | flexi_logger = "0.11.0" | 25 | flexi_logger = "0.11.0" |
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index d361cf9e6..5ac878c79 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -59,6 +59,7 @@ use rustc_hash::FxHashMap; | |||
59 | use ra_arena::{Arena, RawId, impl_arena_id}; | 59 | use ra_arena::{Arena, RawId, impl_arena_id}; |
60 | use ra_db::{FileId, Edition}; | 60 | use ra_db::{FileId, Edition}; |
61 | use test_utils::tested_by; | 61 | use test_utils::tested_by; |
62 | use ra_prof::profile; | ||
62 | 63 | ||
63 | use crate::{ | 64 | use crate::{ |
64 | ModuleDef, Name, Crate, Module, Problem, | 65 | ModuleDef, Name, Crate, Module, Problem, |
@@ -197,7 +198,7 @@ enum ReachedFixedPoint { | |||
197 | 198 | ||
198 | impl CrateDefMap { | 199 | impl CrateDefMap { |
199 | pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: Crate) -> Arc<CrateDefMap> { | 200 | pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: Crate) -> Arc<CrateDefMap> { |
200 | let start = std::time::Instant::now(); | 201 | let _p = profile("crate_def_map_query"); |
201 | let def_map = { | 202 | let def_map = { |
202 | let edition = krate.edition(db); | 203 | let edition = krate.edition(db); |
203 | let mut modules: Arena<CrateModuleId, ModuleData> = Arena::default(); | 204 | let mut modules: Arena<CrateModuleId, ModuleData> = Arena::default(); |
@@ -216,7 +217,6 @@ impl CrateDefMap { | |||
216 | } | 217 | } |
217 | }; | 218 | }; |
218 | let def_map = collector::collect_defs(db, def_map); | 219 | let def_map = collector::collect_defs(db, def_map); |
219 | log::info!("crate_def_map_query: {:?}", start.elapsed()); | ||
220 | Arc::new(def_map) | 220 | Arc::new(def_map) |
221 | } | 221 | } |
222 | 222 | ||
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index d82410700..bc181e4eb 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -27,6 +27,7 @@ ra_ide_api = { path = "../ra_ide_api" } | |||
27 | ra_arena = { path = "../ra_arena" } | 27 | ra_arena = { path = "../ra_arena" } |
28 | gen_lsp_server = { path = "../gen_lsp_server" } | 28 | gen_lsp_server = { path = "../gen_lsp_server" } |
29 | ra_project_model = { path = "../ra_project_model" } | 29 | ra_project_model = { path = "../ra_project_model" } |
30 | ra_prof = { path = "../ra_prof" } | ||
30 | 31 | ||
31 | [dev-dependencies] | 32 | [dev-dependencies] |
32 | tempfile = "3" | 33 | tempfile = "3" |
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 5a2905207..eb4091a3d 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs | |||
@@ -3,6 +3,7 @@ use flexi_logger::{Duplicate, Logger}; | |||
3 | use gen_lsp_server::{run_server, stdio_transport}; | 3 | use gen_lsp_server::{run_server, stdio_transport}; |
4 | 4 | ||
5 | use ra_lsp_server::{Result, InitializationOptions}; | 5 | use ra_lsp_server::{Result, InitializationOptions}; |
6 | use ra_prof; | ||
6 | 7 | ||
7 | fn main() -> Result<()> { | 8 | fn main() -> Result<()> { |
8 | ::std::env::set_var("RUST_BACKTRACE", "short"); | 9 | ::std::env::set_var("RUST_BACKTRACE", "short"); |
@@ -11,6 +12,15 @@ fn main() -> Result<()> { | |||
11 | Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, | 12 | Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, |
12 | _ => logger.start()?, | 13 | _ => logger.start()?, |
13 | }; | 14 | }; |
15 | let prof_depth = match ::std::env::var("RA_PROFILE_DEPTH") { | ||
16 | Ok(ref d) => d.parse()?, | ||
17 | _ => 0, | ||
18 | }; | ||
19 | let profile_allowed = match ::std::env::var("RA_PROFILE") { | ||
20 | Ok(ref p) => p.split(";").map(String::from).collect(), | ||
21 | _ => Vec::new(), | ||
22 | }; | ||
23 | ra_prof::set_filter(ra_prof::Filter::new(prof_depth, profile_allowed)); | ||
14 | log::info!("lifecycle: server started"); | 24 | log::info!("lifecycle: server started"); |
15 | match ::std::panic::catch_unwind(main_inner) { | 25 | match ::std::panic::catch_unwind(main_inner) { |
16 | Ok(res) => { | 26 | Ok(res) => { |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index eecf278a8..82410bee3 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -24,6 +24,7 @@ use crate::{ | |||
24 | Result, | 24 | Result, |
25 | InitializationOptions, | 25 | InitializationOptions, |
26 | }; | 26 | }; |
27 | use ra_prof::profile; | ||
27 | 28 | ||
28 | #[derive(Debug, Fail)] | 29 | #[derive(Debug, Fail)] |
29 | #[fail(display = "Language Server request failed with {}. ({})", code, message)] | 30 | #[fail(display = "Language Server request failed with {}. ({})", code, message)] |
@@ -181,7 +182,7 @@ fn main_loop_inner( | |||
181 | recv(libdata_receiver) -> data => Event::Lib(data.unwrap()) | 182 | recv(libdata_receiver) -> data => Event::Lib(data.unwrap()) |
182 | }; | 183 | }; |
183 | log::info!("loop_turn = {:?}", event); | 184 | log::info!("loop_turn = {:?}", event); |
184 | let start = std::time::Instant::now(); | 185 | let _p = profile("loop_turn"); |
185 | let mut state_changed = false; | 186 | let mut state_changed = false; |
186 | match event { | 187 | match event { |
187 | Event::Task(task) => on_task(task, msg_sender, pending_requests), | 188 | Event::Task(task) => on_task(task, msg_sender, pending_requests), |
@@ -235,10 +236,9 @@ fn main_loop_inner( | |||
235 | in_flight_libraries += 1; | 236 | in_flight_libraries += 1; |
236 | let sender = libdata_sender.clone(); | 237 | let sender = libdata_sender.clone(); |
237 | pool.execute(move || { | 238 | pool.execute(move || { |
238 | let start = ::std::time::Instant::now(); | ||
239 | log::info!("indexing {:?} ... ", root); | 239 | log::info!("indexing {:?} ... ", root); |
240 | let _p = profile(&format!("indexed {:?}", root)); | ||
240 | let data = LibraryData::prepare(root, files); | 241 | let data = LibraryData::prepare(root, files); |
241 | log::info!("indexed {:?} {:?}", start.elapsed(), root); | ||
242 | sender.send(data).unwrap(); | 242 | sender.send(data).unwrap(); |
243 | }); | 243 | }); |
244 | } | 244 | } |
@@ -266,7 +266,6 @@ fn main_loop_inner( | |||
266 | subs.subscriptions(), | 266 | subs.subscriptions(), |
267 | ) | 267 | ) |
268 | } | 268 | } |
269 | log::info!("loop_turn = {:?}", start.elapsed()); | ||
270 | } | 269 | } |
271 | } | 270 | } |
272 | 271 | ||
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 0107f7de9..abddff960 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -52,6 +52,12 @@ pub struct Filter { | |||
52 | allowed: Vec<String>, | 52 | allowed: Vec<String>, |
53 | } | 53 | } |
54 | 54 | ||
55 | impl Filter { | ||
56 | pub fn new(depth: usize, allowed: Vec<String>) -> Filter { | ||
57 | Filter { depth, allowed } | ||
58 | } | ||
59 | } | ||
60 | |||
55 | struct ProfileStack { | 61 | struct ProfileStack { |
56 | starts: Vec<Instant>, | 62 | starts: Vec<Instant>, |
57 | messages: Vec<Message>, | 63 | messages: Vec<Message>, |