Skip to content

Commit

Permalink
[Move analyzer] Increased stack size of initial symbolication run
Browse files Browse the repository at this point in the history
Closes: #479
  • Loading branch information
awelc authored and bors-diem committed Mar 21, 2023
1 parent 4a41ad6 commit 725168d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
27 changes: 19 additions & 8 deletions language/move-analyzer/src/bin/move-analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::{
collections::BTreeMap,
path::Path,
sync::{Arc, Mutex},
thread,
};

use move_analyzer::{
Expand Down Expand Up @@ -47,10 +48,11 @@ fn main() {
);

let (connection, io_threads) = Connection::stdio();
let symbols = Arc::new(Mutex::new(symbols::Symbolicator::empty_symbols()));
let mut context = Context {
connection,
files: VirtualFileSystem::default(),
symbols: Arc::new(Mutex::new(symbols::Symbolicator::empty_symbols())),
symbols: symbols.clone(),
};

let (id, client_response) = context
Expand Down Expand Up @@ -114,8 +116,7 @@ fn main() {
serde_json::from_value(client_response)
.expect("could not deserialize client capabilities");

symbolicator_runner =
symbols::SymbolicatorRunner::new(context.symbols.clone(), diag_sender);
symbolicator_runner = symbols::SymbolicatorRunner::new(symbols.clone(), diag_sender);

// If initialization information from the client contains a path to the directory being
// opened, try to initialize symbols before sending response to the client. Do not bother
Expand All @@ -124,11 +125,21 @@ fn main() {
// to be available right after the client is initialized.
if let Some(uri) = initialize_params.root_uri {
if let Some(p) = symbols::SymbolicatorRunner::root_dir(&uri.to_file_path().unwrap()) {
if let Ok((Some(new_symbols), _)) = symbols::Symbolicator::get_symbols(p.as_path())
{
let mut old_symbols = context.symbols.lock().unwrap();
(*old_symbols).merge(new_symbols);
}
// need to evaluate in a separate thread to allow for a larger stack size (needed on
// Windows)
thread::Builder::new()
.stack_size(symbols::STACK_SIZE_BYTES)
.spawn(move || {
if let Ok((Some(new_symbols), _)) =
symbols::Symbolicator::get_symbols(p.as_path())
{
let mut old_symbols = symbols.lock().unwrap();
(*old_symbols).merge(new_symbols);
}
})
.unwrap()
.join()
.unwrap();
}
}
};
Expand Down
5 changes: 4 additions & 1 deletion language/move-analyzer/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ use move_symbol_pool::Symbol;
/// Enabling/disabling the language server reporting readiness to support go-to-def and
/// go-to-references to the IDE.
pub const DEFS_AND_REFS_SUPPORT: bool = true;
// Building Move code requires a larger stack size on Windows (16M has been chosen somewhat
// arbitrarily)
pub const STACK_SIZE_BYTES: usize = 16 * 1024 * 1024;

#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Copy)]
/// Location of a definition's identifier
Expand Down Expand Up @@ -334,7 +337,7 @@ impl SymbolicatorRunner {
let runner = SymbolicatorRunner { mtx_cvar };

thread::Builder::new()
.stack_size(16 * 1024 * 1024) // building Move code requires a larger stack size on Windows
.stack_size(STACK_SIZE_BYTES)
.spawn(move || {
let (mtx, cvar) = &*thread_mtx_cvar;
// Locations opened in the IDE (files or directories) for which manifest file is missing
Expand Down

0 comments on commit 725168d

Please sign in to comment.