@@ -73,7 +73,7 @@ config_data! {
7373 /// Warm up caches on project load.
7474 cachePriming_enable: bool = true ,
7575 /// How many worker threads to handle priming caches. The default `0` means to pick automatically.
76- cachePriming_numThreads: ParallelCachePrimingNumThreads = 0u8 ,
76+ cachePriming_numThreads: NumThreads = NumThreads :: Physical ,
7777
7878 /// Pass `--all-targets` to cargo invocation.
7979 cargo_allTargets: bool = true ,
@@ -583,7 +583,7 @@ config_data! {
583583 notifications_unindexedProject: bool = false ,
584584
585585 /// How many worker threads in the main loop. The default `null` means to pick automatically.
586- numThreads: Option <usize > = None ,
586+ numThreads: Option <NumThreads > = None ,
587587
588588 /// Expand attribute macros. Requires `#rust-analyzer.procMacro.enable#` to be set.
589589 procMacro_attributes_enable: bool = true ,
@@ -2095,15 +2095,22 @@ impl Config {
20952095 }
20962096 }
20972097
2098- pub fn prime_caches_num_threads ( & self ) -> u8 {
2099- match * self . cachePriming_numThreads ( ) {
2100- 0 => num_cpus:: get_physical ( ) . try_into ( ) . unwrap_or ( u8:: MAX ) ,
2101- n => n,
2098+ pub fn prime_caches_num_threads ( & self ) -> usize {
2099+ match self . cachePriming_numThreads ( ) {
2100+ NumThreads :: Concrete ( 0 ) | NumThreads :: Physical => num_cpus:: get_physical ( ) ,
2101+ & NumThreads :: Concrete ( n) => n,
2102+ NumThreads :: Logical => num_cpus:: get ( ) ,
21022103 }
21032104 }
21042105
21052106 pub fn main_loop_num_threads ( & self ) -> usize {
2106- self . numThreads ( ) . unwrap_or ( num_cpus:: get_physical ( ) )
2107+ match self . numThreads ( ) {
2108+ Some ( NumThreads :: Concrete ( 0 ) ) | None | Some ( NumThreads :: Physical ) => {
2109+ num_cpus:: get_physical ( )
2110+ }
2111+ & Some ( NumThreads :: Concrete ( n) ) => n,
2112+ Some ( NumThreads :: Logical ) => num_cpus:: get ( ) ,
2113+ }
21072114 }
21082115
21092116 pub fn typing_autoclose_angle ( & self ) -> bool {
@@ -2524,6 +2531,15 @@ pub enum TargetDirectory {
25242531 Directory ( Utf8PathBuf ) ,
25252532}
25262533
2534+ #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq ) ]
2535+ #[ serde( rename_all = "snake_case" ) ]
2536+ #[ serde( untagged) ]
2537+ pub enum NumThreads {
2538+ Physical ,
2539+ Logical ,
2540+ Concrete ( usize ) ,
2541+ }
2542+
25272543macro_rules! _default_val {
25282544 ( @verbatim: $s: literal, $ty: ty) => { {
25292545 let default_: $ty = serde_json:: from_str( & $s) . unwrap( ) ;
@@ -3260,6 +3276,24 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
32603276 } ,
32613277 ] ,
32623278 } ,
3279+ "Option<NumThreads>" => set ! {
3280+ "anyOf" : [
3281+ {
3282+ "type" : "null"
3283+ } ,
3284+ {
3285+ "type" : "number"
3286+ } ,
3287+ {
3288+ "type" : "string" ,
3289+ "enum" : [ "physical" , "logical" , ] ,
3290+ "enumDescriptions" : [
3291+ "Use the number of physical cores" ,
3292+ "Use the number of logical cores" ,
3293+ ] ,
3294+ } ,
3295+ ] ,
3296+ } ,
32633297 _ => panic ! ( "missing entry for {ty}: {default}" ) ,
32643298 }
32653299
0 commit comments