Skip to content

Commit 725168d

Browse files
awelcbors-diem
authored andcommitted
[Move analyzer] Increased stack size of initial symbolication run
Closes: #479
1 parent 4a41ad6 commit 725168d

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

language/move-analyzer/src/bin/move-analyzer.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{
1414
collections::BTreeMap,
1515
path::Path,
1616
sync::{Arc, Mutex},
17+
thread,
1718
};
1819

1920
use move_analyzer::{
@@ -47,10 +48,11 @@ fn main() {
4748
);
4849

4950
let (connection, io_threads) = Connection::stdio();
51+
let symbols = Arc::new(Mutex::new(symbols::Symbolicator::empty_symbols()));
5052
let mut context = Context {
5153
connection,
5254
files: VirtualFileSystem::default(),
53-
symbols: Arc::new(Mutex::new(symbols::Symbolicator::empty_symbols())),
55+
symbols: symbols.clone(),
5456
};
5557

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

117-
symbolicator_runner =
118-
symbols::SymbolicatorRunner::new(context.symbols.clone(), diag_sender);
119+
symbolicator_runner = symbols::SymbolicatorRunner::new(symbols.clone(), diag_sender);
119120

120121
// If initialization information from the client contains a path to the directory being
121122
// opened, try to initialize symbols before sending response to the client. Do not bother
@@ -124,11 +125,21 @@ fn main() {
124125
// to be available right after the client is initialized.
125126
if let Some(uri) = initialize_params.root_uri {
126127
if let Some(p) = symbols::SymbolicatorRunner::root_dir(&uri.to_file_path().unwrap()) {
127-
if let Ok((Some(new_symbols), _)) = symbols::Symbolicator::get_symbols(p.as_path())
128-
{
129-
let mut old_symbols = context.symbols.lock().unwrap();
130-
(*old_symbols).merge(new_symbols);
131-
}
128+
// need to evaluate in a separate thread to allow for a larger stack size (needed on
129+
// Windows)
130+
thread::Builder::new()
131+
.stack_size(symbols::STACK_SIZE_BYTES)
132+
.spawn(move || {
133+
if let Ok((Some(new_symbols), _)) =
134+
symbols::Symbolicator::get_symbols(p.as_path())
135+
{
136+
let mut old_symbols = symbols.lock().unwrap();
137+
(*old_symbols).merge(new_symbols);
138+
}
139+
})
140+
.unwrap()
141+
.join()
142+
.unwrap();
132143
}
133144
}
134145
};

language/move-analyzer/src/symbols.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ use move_symbol_pool::Symbol;
9090
/// Enabling/disabling the language server reporting readiness to support go-to-def and
9191
/// go-to-references to the IDE.
9292
pub const DEFS_AND_REFS_SUPPORT: bool = true;
93+
// Building Move code requires a larger stack size on Windows (16M has been chosen somewhat
94+
// arbitrarily)
95+
pub const STACK_SIZE_BYTES: usize = 16 * 1024 * 1024;
9396

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

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

0 commit comments

Comments
 (0)