This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,9 @@ config_data! {
403403 /// Whether to show `can't find Cargo.toml` error message.
404404 notifications_cargoTomlNotFound: bool = "true" ,
405405
406+ /// How many worker threads in the main loop. The default `null` means to pick automatically.
407+ numThreads: Option <usize > = "null" ,
408+
406409 /// Expand attribute macros. Requires `#rust-analyzer.procMacro.enable#` to be set.
407410 procMacro_attributes_enable: bool = "true" ,
408411 /// Enable support for procedural macros, implies `#rust-analyzer.cargo.buildScripts.enable#`.
@@ -1454,6 +1457,10 @@ impl Config {
14541457 }
14551458 }
14561459
1460+ pub fn main_loop_num_threads ( & self ) -> usize {
1461+ self . data . numThreads . unwrap_or ( num_cpus:: get_physical ( ) . try_into ( ) . unwrap_or ( 1 ) )
1462+ }
1463+
14571464 pub fn typing_autoclose_angle ( & self ) -> bool {
14581465 self . data . typing_autoClosingAngleBrackets_enable
14591466 }
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ impl GlobalState {
134134
135135 let task_pool = {
136136 let ( sender, receiver) = unbounded ( ) ;
137- let handle = TaskPool :: new ( sender) ;
137+ let handle = TaskPool :: new_with_threads ( sender, config . main_loop_num_threads ( ) ) ;
138138 Handle { handle, receiver }
139139 } ;
140140
Original file line number Diff line number Diff line change @@ -8,12 +8,13 @@ pub(crate) struct TaskPool<T> {
88}
99
1010impl < T > TaskPool < T > {
11- pub ( crate ) fn new ( sender : Sender < T > ) -> TaskPool < T > {
11+ pub ( crate ) fn new_with_threads ( sender : Sender < T > , threads : usize ) -> TaskPool < T > {
1212 const STACK_SIZE : usize = 8 * 1024 * 1024 ;
1313
1414 let inner = threadpool:: Builder :: new ( )
1515 . thread_name ( "Worker" . into ( ) )
1616 . thread_stack_size ( STACK_SIZE )
17+ . num_threads ( threads)
1718 . build ( ) ;
1819 TaskPool { sender, inner }
1920 }
You can’t perform that action at this time.
0 commit comments