Skip to content

Commit 53d2050

Browse files
committed
feat: improve CPU usage
closes #9922 Turned out to be trivial after preliminary refactor. The intended behavior is that we schedule cache priming once ws become quiescent (that is, we fully load cargo project), and we continue to rschedule it until it completes (priming might get cancelled by user typing into a file).
1 parent 9e0203b commit 53d2050

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,15 @@ impl GlobalState {
296296
));
297297
fraction = Progress::fraction(report.n_done, report.n_total);
298298
}
299-
PrimeCachesProgress::End { cancelled: _ } => {
299+
PrimeCachesProgress::End { cancelled } => {
300300
state = Progress::End;
301301
message = None;
302302
fraction = 1.0;
303303

304304
self.prime_caches_queue.op_completed(());
305+
if cancelled {
306+
self.prime_caches_queue.request_op();
307+
}
305308
}
306309
};
307310

@@ -424,11 +427,10 @@ impl GlobalState {
424427
for flycheck in &self.flycheck {
425428
flycheck.update();
426429
}
430+
self.prime_caches_queue.request_op();
427431
}
428432

429433
if !was_quiescent || state_changed {
430-
self.prime_caches_queue.request_op();
431-
432434
// Refresh semantic tokens if the client supports it.
433435
if self.config.semantic_tokens_refresh() {
434436
self.semantic_tokens_cache.lock().clear();

0 commit comments

Comments
 (0)