mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
PR issuse resolved
This commit is contained in:
parent
ef02c3c038
commit
9b73f80959
9 changed files with 30 additions and 10 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -930,6 +930,7 @@ dependencies = [
|
|||
"ra_hir 0.1.0",
|
||||
"ra_ide_api 0.1.0",
|
||||
"ra_ide_api_light 0.1.0",
|
||||
"ra_prof 0.1.0",
|
||||
"ra_syntax 0.1.0",
|
||||
"tools 0.1.0",
|
||||
]
|
||||
|
@ -969,6 +970,7 @@ dependencies = [
|
|||
"ra_arena 0.1.0",
|
||||
"ra_db 0.1.0",
|
||||
"ra_mbe 0.1.0",
|
||||
"ra_prof 0.1.0",
|
||||
"ra_syntax 0.1.0",
|
||||
"ra_tt 0.1.0",
|
||||
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1034,6 +1036,7 @@ dependencies = [
|
|||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ra_arena 0.1.0",
|
||||
"ra_ide_api 0.1.0",
|
||||
"ra_prof 0.1.0",
|
||||
"ra_project_model 0.1.0",
|
||||
"ra_syntax 0.1.0",
|
||||
"ra_text_edit 0.1.0",
|
||||
|
|
|
@ -19,3 +19,4 @@ tools = { path = "../tools" }
|
|||
ra_batch = { path = "../ra_batch" }
|
||||
ra_hir = { path = "../ra_hir" }
|
||||
ra_db = { path = "../ra_db" }
|
||||
ra_prof = { path = "../ra_prof" }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod analysis_stats;
|
||||
|
||||
use std::{fs, io::Read, path::Path, time::Instant};
|
||||
use std::{fs, io::Read, path::Path};
|
||||
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use join_to_string::join;
|
||||
|
@ -9,6 +9,7 @@ use ra_ide_api_light::file_structure;
|
|||
use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode};
|
||||
use tools::collect_tests;
|
||||
use flexi_logger::Logger;
|
||||
use ra_prof::profile;
|
||||
|
||||
type Result<T> = ::std::result::Result<T, failure::Error>;
|
||||
|
||||
|
@ -34,13 +35,11 @@ fn main() -> Result<()> {
|
|||
.get_matches();
|
||||
match matches.subcommand() {
|
||||
("parse", Some(matches)) => {
|
||||
let start = Instant::now();
|
||||
let _p = profile("parsing");
|
||||
let file = file()?;
|
||||
let elapsed = start.elapsed();
|
||||
if !matches.is_present("no-dump") {
|
||||
println!("{}", file.syntax().debug_dump());
|
||||
}
|
||||
eprintln!("parsing: {:?}", elapsed);
|
||||
::std::mem::forget(file);
|
||||
}
|
||||
("symbols", _) => {
|
||||
|
|
|
@ -19,6 +19,7 @@ ra_db = { path = "../ra_db" }
|
|||
mbe = { path = "../ra_mbe", package = "ra_mbe" }
|
||||
tt = { path = "../ra_tt", package = "ra_tt" }
|
||||
test_utils = { path = "../test_utils" }
|
||||
ra_prof = {path = "../ra_prof" }
|
||||
|
||||
[dev-dependencies]
|
||||
flexi_logger = "0.11.0"
|
||||
|
|
|
@ -59,6 +59,7 @@ use rustc_hash::FxHashMap;
|
|||
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||
use ra_db::{FileId, Edition};
|
||||
use test_utils::tested_by;
|
||||
use ra_prof::profile;
|
||||
|
||||
use crate::{
|
||||
ModuleDef, Name, Crate, Module, Problem,
|
||||
|
@ -197,7 +198,7 @@ enum ReachedFixedPoint {
|
|||
|
||||
impl CrateDefMap {
|
||||
pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: Crate) -> Arc<CrateDefMap> {
|
||||
let start = std::time::Instant::now();
|
||||
let _p = profile("crate_def_map_query");
|
||||
let def_map = {
|
||||
let edition = krate.edition(db);
|
||||
let mut modules: Arena<CrateModuleId, ModuleData> = Arena::default();
|
||||
|
@ -216,7 +217,6 @@ impl CrateDefMap {
|
|||
}
|
||||
};
|
||||
let def_map = collector::collect_defs(db, def_map);
|
||||
log::info!("crate_def_map_query: {:?}", start.elapsed());
|
||||
Arc::new(def_map)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ ra_ide_api = { path = "../ra_ide_api" }
|
|||
ra_arena = { path = "../ra_arena" }
|
||||
gen_lsp_server = { path = "../gen_lsp_server" }
|
||||
ra_project_model = { path = "../ra_project_model" }
|
||||
ra_prof = { path = "../ra_prof" }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
|
|
@ -3,6 +3,7 @@ use flexi_logger::{Duplicate, Logger};
|
|||
use gen_lsp_server::{run_server, stdio_transport};
|
||||
|
||||
use ra_lsp_server::{Result, InitializationOptions};
|
||||
use ra_prof;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
::std::env::set_var("RUST_BACKTRACE", "short");
|
||||
|
@ -11,6 +12,15 @@ fn main() -> Result<()> {
|
|||
Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?,
|
||||
_ => logger.start()?,
|
||||
};
|
||||
let prof_depth = match ::std::env::var("RA_PROFILE_DEPTH") {
|
||||
Ok(ref d) => d.parse()?,
|
||||
_ => 0,
|
||||
};
|
||||
let profile_allowed = match ::std::env::var("RA_PROFILE") {
|
||||
Ok(ref p) => p.split(";").map(String::from).collect(),
|
||||
_ => Vec::new(),
|
||||
};
|
||||
ra_prof::set_filter(ra_prof::Filter::new(prof_depth, profile_allowed));
|
||||
log::info!("lifecycle: server started");
|
||||
match ::std::panic::catch_unwind(main_inner) {
|
||||
Ok(res) => {
|
||||
|
|
|
@ -24,6 +24,7 @@ use crate::{
|
|||
Result,
|
||||
InitializationOptions,
|
||||
};
|
||||
use ra_prof::profile;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
#[fail(display = "Language Server request failed with {}. ({})", code, message)]
|
||||
|
@ -181,7 +182,7 @@ fn main_loop_inner(
|
|||
recv(libdata_receiver) -> data => Event::Lib(data.unwrap())
|
||||
};
|
||||
log::info!("loop_turn = {:?}", event);
|
||||
let start = std::time::Instant::now();
|
||||
let _p = profile("loop_turn");
|
||||
let mut state_changed = false;
|
||||
match event {
|
||||
Event::Task(task) => on_task(task, msg_sender, pending_requests),
|
||||
|
@ -235,10 +236,9 @@ fn main_loop_inner(
|
|||
in_flight_libraries += 1;
|
||||
let sender = libdata_sender.clone();
|
||||
pool.execute(move || {
|
||||
let start = ::std::time::Instant::now();
|
||||
log::info!("indexing {:?} ... ", root);
|
||||
let _p = profile(&format!("indexed {:?}", root));
|
||||
let data = LibraryData::prepare(root, files);
|
||||
log::info!("indexed {:?} {:?}", start.elapsed(), root);
|
||||
sender.send(data).unwrap();
|
||||
});
|
||||
}
|
||||
|
@ -266,7 +266,6 @@ fn main_loop_inner(
|
|||
subs.subscriptions(),
|
||||
)
|
||||
}
|
||||
log::info!("loop_turn = {:?}", start.elapsed());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,12 @@ pub struct Filter {
|
|||
allowed: Vec<String>,
|
||||
}
|
||||
|
||||
impl Filter {
|
||||
pub fn new(depth: usize, allowed: Vec<String>) -> Filter {
|
||||
Filter { depth, allowed }
|
||||
}
|
||||
}
|
||||
|
||||
struct ProfileStack {
|
||||
starts: Vec<Instant>,
|
||||
messages: Vec<Message>,
|
||||
|
|
Loading…
Reference in a new issue