make it a config
This commit is contained in:
@@ -298,6 +298,9 @@ config_data! {
|
||||
/// Whether to show `can't find Cargo.toml` error message.
|
||||
notifications_cargoTomlNotFound: bool = "true",
|
||||
|
||||
/// How many worker threads to to handle priming caches. The default `0` means to pick automatically.
|
||||
primeCaches_numThreads: ParallelPrimeCachesNumThreads = "0",
|
||||
|
||||
/// Enable support for procedural macros, implies `#rust-analyzer.cargo.runBuildScripts#`.
|
||||
procMacro_enable: bool = "true",
|
||||
/// Internal config, path to proc-macro server executable (typically,
|
||||
@@ -1016,6 +1019,13 @@ impl Config {
|
||||
yield_points: self.data.highlightRelated_yieldPoints,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prime_caches_num_threads(&self) -> u8 {
|
||||
match self.data.primeCaches_numThreads {
|
||||
0 => num_cpus::get_physical().try_into().unwrap_or(u8::MAX),
|
||||
n => n,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy)]
|
||||
@@ -1130,6 +1140,8 @@ enum WorkspaceSymbolSearchKindDef {
|
||||
AllSymbols,
|
||||
}
|
||||
|
||||
type ParallelPrimeCachesNumThreads = u8;
|
||||
|
||||
macro_rules! _config_data {
|
||||
(struct $name:ident {
|
||||
$(
|
||||
@@ -1351,6 +1363,11 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
||||
"Search for all symbols kinds"
|
||||
],
|
||||
},
|
||||
"ParallelPrimeCachesNumThreads" => set! {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
_ => panic!("{}: {}", ty, default),
|
||||
}
|
||||
|
||||
|
||||
@@ -505,17 +505,16 @@ impl GlobalState {
|
||||
self.fetch_build_data();
|
||||
}
|
||||
if self.prime_caches_queue.should_start_op() {
|
||||
let num_worker_threads = self.config.prime_caches_num_threads();
|
||||
|
||||
self.task_pool.handle.spawn_with_sender({
|
||||
let analysis = self.snapshot().analysis;
|
||||
move |sender| {
|
||||
sender.send(Task::PrimeCaches(PrimeCachesProgress::Begin)).unwrap();
|
||||
let res = analysis.parallel_prime_caches(
|
||||
num_cpus::get_physical().try_into().unwrap_or(u8::MAX),
|
||||
|progress| {
|
||||
let report = PrimeCachesProgress::Report(progress);
|
||||
sender.send(Task::PrimeCaches(report)).unwrap();
|
||||
},
|
||||
);
|
||||
let res = analysis.parallel_prime_caches(num_worker_threads, |progress| {
|
||||
let report = PrimeCachesProgress::Report(progress);
|
||||
sender.send(Task::PrimeCaches(report)).unwrap();
|
||||
});
|
||||
sender
|
||||
.send(Task::PrimeCaches(PrimeCachesProgress::End {
|
||||
cancelled: res.is_err(),
|
||||
|
||||
Reference in New Issue
Block a user