Skip to content

Commit fac08dc

Browse files
Add a --num-threads to the prime-caches CLI command
And make it parallel by default (and remove the `--parallel` flag) to mirror the IDE cache priming.
1 parent 7223e56 commit fac08dc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/rust-analyzer/src/cli/flags.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ xflags::xflags! {
150150
optional --disable-proc-macros
151151
/// Run the proc-macro-srv binary at the specified path.
152152
optional --proc-macro-srv path: PathBuf
153-
/// Run cache priming in parallel.
154-
optional --parallel
153+
/// The number of threads to use. Defaults to the number of physical cores.
154+
optional --num-threads num_threads: usize
155155
}
156156

157157
cmd ssr {
@@ -299,7 +299,7 @@ pub struct PrimeCaches {
299299
pub disable_build_scripts: bool,
300300
pub disable_proc_macros: bool,
301301
pub proc_macro_srv: Option<PathBuf>,
302-
pub parallel: bool,
302+
pub num_threads: Option<usize>,
303303
}
304304

305305
#[derive(Debug)]

crates/rust-analyzer/src/cli/prime_caches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl flags::PrimeCaches {
5252
elapsed.memory.allocated.megabytes() as u64
5353
);
5454

55-
let threads = if self.parallel { num_cpus::get() } else { 1 };
55+
let threads = self.num_threads.unwrap_or_else(num_cpus::get_physical);
5656
ide_db::prime_caches::parallel_prime_caches(&db, threads, &|_| ());
5757

5858
let elapsed = stop_watch.elapsed();

0 commit comments

Comments
 (0)