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! {
403
403
/// Whether to show `can't find Cargo.toml` error message.
404
404
notifications_cargoTomlNotFound: bool = "true" ,
405
405
406
+ /// How many worker threads in the main loop. The default `null` means to pick automatically.
407
+ numThreads: Option <usize > = "null" ,
408
+
406
409
/// Expand attribute macros. Requires `#rust-analyzer.procMacro.enable#` to be set.
407
410
procMacro_attributes_enable: bool = "true" ,
408
411
/// Enable support for procedural macros, implies `#rust-analyzer.cargo.buildScripts.enable#`.
@@ -1454,6 +1457,10 @@ impl Config {
1454
1457
}
1455
1458
}
1456
1459
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
+
1457
1464
pub fn typing_autoclose_angle ( & self ) -> bool {
1458
1465
self . data . typing_autoClosingAngleBrackets_enable
1459
1466
}
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ impl GlobalState {
134
134
135
135
let task_pool = {
136
136
let ( sender, receiver) = unbounded ( ) ;
137
- let handle = TaskPool :: new ( sender) ;
137
+ let handle = TaskPool :: new_with_threads ( sender, config . main_loop_num_threads ( ) ) ;
138
138
Handle { handle, receiver }
139
139
} ;
140
140
Original file line number Diff line number Diff line change @@ -8,12 +8,13 @@ pub(crate) struct TaskPool<T> {
8
8
}
9
9
10
10
impl < 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 > {
12
12
const STACK_SIZE : usize = 8 * 1024 * 1024 ;
13
13
14
14
let inner = threadpool:: Builder :: new ( )
15
15
. thread_name ( "Worker" . into ( ) )
16
16
. thread_stack_size ( STACK_SIZE )
17
+ . num_threads ( threads)
17
18
. build ( ) ;
18
19
TaskPool { sender, inner }
19
20
}
You can’t perform that action at this time.
0 commit comments