Skip to content

Commit 25d577e

Browse files
committed
perf(language_server): start tools in parallel (#15500)
1 parent 77c5d30 commit 25d577e

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

crates/oxc_language_server/src/worker.rs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,19 @@ impl WorkspaceWorker {
6767
/// Start all programs (linter, formatter) for the worker.
6868
/// This should be called after the client has sent the workspace configuration.
6969
pub async fn start_worker(&self, options: serde_json::Value) {
70-
*self.options.lock().await = Some(options.clone());
71-
*self.server_linter.write().await =
72-
Some(ServerLinterBuilder::new(self.root_uri.clone(), options.clone()).build());
70+
tokio::join!(
71+
async {
72+
*self.server_linter.write().await =
73+
Some(ServerLinterBuilder::new(self.root_uri.clone(), options.clone()).build());
74+
},
75+
async {
76+
*self.server_formatter.write().await = Some(
77+
ServerFormatterBuilder::new(self.root_uri.clone(), options.clone()).build(),
78+
);
79+
},
80+
);
7381

74-
*self.server_formatter.write().await =
75-
Some(ServerFormatterBuilder::new(self.root_uri.clone(), options).build());
82+
*self.options.lock().await = Some(options);
7683
}
7784

7885
/// Initialize file system watchers for the workspace.
@@ -84,18 +91,22 @@ impl WorkspaceWorker {
8491
// clone the options to avoid locking the mutex
8592
let options_json = { self.options.lock().await.clone().unwrap_or_default() };
8693

87-
let lint_patterns = self
88-
.server_linter
89-
.read()
90-
.await
91-
.as_ref()
92-
.map(|linter| linter.get_watcher_patterns(options_json.clone()));
93-
let format_patterns = self
94-
.server_formatter
95-
.read()
96-
.await
97-
.as_ref()
98-
.map(|formatter| formatter.get_watcher_patterns(options_json));
94+
let (lint_patterns, format_patterns) = tokio::join!(
95+
async {
96+
self.server_linter
97+
.read()
98+
.await
99+
.as_ref()
100+
.map(|linter| linter.get_watcher_patterns(options_json.clone()))
101+
},
102+
async {
103+
self.server_formatter
104+
.read()
105+
.await
106+
.as_ref()
107+
.map(|formatter| formatter.get_watcher_patterns(options_json.clone()))
108+
}
109+
);
99110

100111
if let Some(lint_patterns) = lint_patterns
101112
&& !lint_patterns.is_empty()

0 commit comments

Comments
 (0)