aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_lsp_server/Cargo.toml3
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs19
2 files changed, 22 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index 5df0496dd..fdf81ed87 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -30,6 +30,9 @@ env_logger = { version = "0.7.1", default-features = false }
30ra_cargo_watch = { path = "../ra_cargo_watch" } 30ra_cargo_watch = { path = "../ra_cargo_watch" }
31either = "1.5" 31either = "1.5"
32 32
33[target.'cfg(windows)'.dependencies]
34winapi = "0.3"
35
33[dev-dependencies] 36[dev-dependencies]
34tempfile = "3" 37tempfile = "3"
35test_utils = { path = "../test_utils" } 38test_utils = { path = "../test_utils" }
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 315f4a4d6..15bf519c9 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -57,6 +57,25 @@ pub fn main_loop(
57) -> Result<()> { 57) -> Result<()> {
58 log::info!("server_config: {:#?}", config); 58 log::info!("server_config: {:#?}", config);
59 59
60 // Windows scheduler implements priority boosts: if thread waits for an
61 // event (like a condvar), and event fires, priority of the thread is
62 // temporary bumped. This optimization backfires in our case: each time the
63 // `main_loop` schedules a task to run on a threadpool, the worker threads
64 // gets a higher priority, and (on a machine with fewer cores) displaces the
65 // main loop! We work-around this by marking the main loop as a
66 // higher-priority thread.
67 //
68 // https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities
69 // https://docs.microsoft.com/en-us/windows/win32/procthread/priority-boosts
70 // https://github.com/rust-analyzer/rust-analyzer/issues/2835
71 #[cfg(windows)]
72 unsafe {
73 use winapi::um::processthreadsapi::*;
74 let thread = GetCurrentThread();
75 let thread_priority_above_normal = 1;
76 SetThreadPriority(thread, thread_priority_above_normal);
77 }
78
60 let mut loop_state = LoopState::default(); 79 let mut loop_state = LoopState::default();
61 let mut world_state = { 80 let mut world_state = {
62 let feature_flags = { 81 let feature_flags = {