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 <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2021-11-20 20:24:31 +00:00 committed by GitHub
commit 4566414789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View file

@ -58,6 +58,9 @@ config_data! {
/// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
assist_allowMergingIntoGlobImports: bool = "true",
/// Warm up caches on project load.
cache_warmup: bool = "true",
/// Show function name and docs in parameter hints.
callInfo_full: bool = "true",
@ -545,6 +548,10 @@ impl Config {
)
}
pub fn prefill_caches(&self) -> bool {
self.data.cache_warmup
}
pub fn location_link(&self) -> bool {
try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
}

View file

@ -433,7 +433,9 @@ impl GlobalState {
for flycheck in &self.flycheck {
flycheck.update();
}
self.prime_caches_queue.request_op();
if self.config.prefill_caches() {
self.prime_caches_queue.request_op();
}
}
if !was_quiescent || state_changed {