From 4df965a002b5296fc728f1bc2fb9312fe421ea5d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 4 Sep 2018 04:13:22 +0300 Subject: work --- crates/libanalysis/src/roots.rs | 10 +++++----- crates/server/src/main_loop/mod.rs | 9 ++++++--- crates/server/src/vfs.rs | 6 +++--- crates/server/tests/heavy_tests/main.rs | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'crates') diff --git a/crates/libanalysis/src/roots.rs b/crates/libanalysis/src/roots.rs index f1bc72e33..6d1375f88 100644 --- a/crates/libanalysis/src/roots.rs +++ b/crates/libanalysis/src/roots.rs @@ -138,6 +138,11 @@ pub(crate) struct ReadonlySourceRoot { impl ReadonlySourceRoot { pub fn new(files: Vec<(FileId, String)>) -> ReadonlySourceRoot { let mut module_map = ModuleMap::new(); + let symbol_index = SymbolIndex::for_files( + files.par_iter().map(|(file_id, text)| { + (*file_id, File::parse(text)) + }) + ); let file_map: HashMap = files .into_iter() .map(|(id, text)| { @@ -145,11 +150,6 @@ impl ReadonlySourceRoot { (id, FileData::new(text)) }) .collect(); - let symbol_index = SymbolIndex::for_files( - file_map.par_iter().map(|(&file_id, file_data)| { - (file_id, file_data.syntax_transient()) - }) - ); ReadonlySourceRoot { symbol_index, diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index 58f6f88a7..52e3b661d 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs @@ -8,7 +8,7 @@ use std::{ use threadpool::ThreadPool; use serde::{Serialize, de::DeserializeOwned}; -use crossbeam_channel::{bounded, Sender, Receiver}; +use crossbeam_channel::{unbounded, Sender, Receiver}; use languageserver_types::{NumberOrString}; use libanalysis::{FileId, JobHandle, JobToken, LibraryData}; use gen_lsp_server::{ @@ -38,7 +38,7 @@ pub fn main_loop( msg_sender: &mut Sender, ) -> Result<()> { let pool = ThreadPool::new(4); - let (task_sender, task_receiver) = bounded::(16); + let (task_sender, task_receiver) = unbounded::(); let (fs_sender, fs_receiver, fs_watcher) = vfs::roots_loader(); let (ws_sender, ws_receiver, ws_watcher) = workspace_loader(); @@ -97,7 +97,7 @@ fn main_loop_inner( pending_requests: &mut HashMap, subs: &mut Subscriptions, ) -> Result<()> { - let (libdata_sender, libdata_receiver) = bounded(1024); + let (libdata_sender, libdata_receiver) = unbounded(); ws_sender.send(ws_root.clone()); fs_sender.send(ws_root.clone()); loop { @@ -137,7 +137,10 @@ fn main_loop_inner( let files = state.events_to_files(events); let sender = libdata_sender.clone(); pool.execute(move || { + let start = ::std::time::Instant::now(); + info!("indexing {} ... ", root.display()); let data = LibraryData::prepare(files); + info!("indexed {:?} {}", start.elapsed(), root.display()); sender.send(data); }); } diff --git a/crates/server/src/vfs.rs b/crates/server/src/vfs.rs index 69a7654af..2699fc21e 100644 --- a/crates/server/src/vfs.rs +++ b/crates/server/src/vfs.rs @@ -3,7 +3,7 @@ use std::{ fs, }; -use crossbeam_channel::{Sender, Receiver, bounded}; +use crossbeam_channel::{Sender, Receiver, unbounded}; use walkdir::WalkDir; use { @@ -23,8 +23,8 @@ pub enum FileEventKind { } pub fn roots_loader() -> (Sender, Receiver<(PathBuf, Vec)>, ThreadWatcher) { - let (path_sender, path_receiver) = bounded::(2048); - let (event_sender, event_receiver) = bounded::<(PathBuf, Vec)>(1); + let (path_sender, path_receiver) = unbounded::(); + let (event_sender, event_receiver) = unbounded::<(PathBuf, Vec)>(); let thread = ThreadWatcher::spawn("roots loader", move || { path_receiver .into_iter() diff --git a/crates/server/tests/heavy_tests/main.rs b/crates/server/tests/heavy_tests/main.rs index 66620ac62..50529f453 100644 --- a/crates/server/tests/heavy_tests/main.rs +++ b/crates/server/tests/heavy_tests/main.rs @@ -95,5 +95,5 @@ fn test_eggs() {} // extern crate regex; // "#); // server.wait_for_feedback("workspace loaded"); -// server.wait_for_feedback_n("library loaded", 1); +// server.wait_for_feedback_n("library loaded", 9); // } -- cgit v1.2.3