Skip to content

Commit 4566414

Browse files
bors[bot]lnicola
andauthored
Merge #10810
10810: feat: Add toggle to disable cache priming r=jonas-schievink a=lnicola Even if it doesn't prevent the rest of the features from working, cache priming tends to be quite CPU-intensive and can make people think that the load times are worse than they actually are. It's also less useful in Code and `rust-tools` because the inlay hints and semantic highlighting trigger quite a bit of computation assuming you have a file open in the editor. Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents c9c6fa8 + a68ce62 commit 4566414

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ config_data! {
5858
/// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
5959
assist_allowMergingIntoGlobImports: bool = "true",
6060

61+
/// Warm up caches on project load.
62+
cache_warmup: bool = "true",
63+
6164
/// Show function name and docs in parameter hints.
6265
callInfo_full: bool = "true",
6366

@@ -545,6 +548,10 @@ impl Config {
545548
)
546549
}
547550

551+
pub fn prefill_caches(&self) -> bool {
552+
self.data.cache_warmup
553+
}
554+
548555
pub fn location_link(&self) -> bool {
549556
try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
550557
}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ impl GlobalState {
433433
for flycheck in &self.flycheck {
434434
flycheck.update();
435435
}
436-
self.prime_caches_queue.request_op();
436+
if self.config.prefill_caches() {
437+
self.prime_caches_queue.request_op();
438+
}
437439
}
438440

439441
if !was_quiescent || state_changed {

docs/user/generated_config.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-i
2323
--
2424
Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
2525
--
26+
[[rust-analyzer.cache.warmup]]rust-analyzer.cache.warmup (default: `true`)::
27+
+
28+
--
29+
Warm up caches on project load.
30+
--
2631
[[rust-analyzer.callInfo.full]]rust-analyzer.callInfo.full (default: `true`)::
2732
+
2833
--

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,11 @@
445445
"default": true,
446446
"type": "boolean"
447447
},
448+
"rust-analyzer.cache.warmup": {
449+
"markdownDescription": "Warm up caches on project load.",
450+
"default": true,
451+
"type": "boolean"
452+
},
448453
"rust-analyzer.callInfo.full": {
449454
"markdownDescription": "Show function name and docs in parameter hints.",
450455
"default": true,

0 commit comments

Comments
 (0)