aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-11 07:28:32 +0100
committerGitHub <[email protected]>2021-06-11 07:28:32 +0100
commitc62ec3d9986d45224d4c64ba9b7b22c1d1d0afb2 (patch)
treee69382ca1a8c98a0ff2fd6e0395d6b379f80f705 /crates/ide/src
parentc4c1fcb8e902adcc7879996fa7f53200fb36ce33 (diff)
parent339448157c479f724ae22fce6d5fa78f76c59720 (diff)
Merge #9208
9208: minor: Populate import maps eagerly to speed up flyimports r=SomeoneToIgnore a=SomeoneToIgnore Part of #7542 Follow up of https://github.com/rust-analyzer/rust-analyzer/pull/9206#issuecomment-859097783 Reduces `import_on_the_fly @ sel` case in the `integrated_completion_benchmark` by ~300ms. Also enables cache priming for manual workspace loading to reflect the results in the benchmarks. Before: <img width="1198" alt="image" src="https://user-images.githubusercontent.com/2690773/121606148-4a734a80-ca56-11eb-812a-7955e93817f1.png"> After: <img width="1200" alt="image" src="https://user-images.githubusercontent.com/2690773/121606156-4e06d180-ca56-11eb-891b-1ed878b53d7e.png"> Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/prime_caches.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ide/src/prime_caches.rs b/crates/ide/src/prime_caches.rs
index d912a01b8..36801c964 100644
--- a/crates/ide/src/prime_caches.rs
+++ b/crates/ide/src/prime_caches.rs
@@ -33,14 +33,15 @@ pub(crate) fn prime_caches(db: &RootDatabase, cb: &(dyn Fn(PrimeCachesProgress)
33 // FIXME: This would be easy to parallelize, since it's in the ideal ordering for that. 33 // FIXME: This would be easy to parallelize, since it's in the ideal ordering for that.
34 // Unfortunately rayon prevents panics from propagation out of a `scope`, which breaks 34 // Unfortunately rayon prevents panics from propagation out of a `scope`, which breaks
35 // cancellation, so we cannot use rayon. 35 // cancellation, so we cannot use rayon.
36 for (i, krate) in topo.iter().enumerate() { 36 for (i, &crate_id) in topo.iter().enumerate() {
37 let crate_name = graph[*krate].display_name.as_deref().unwrap_or_default().to_string(); 37 let crate_name = graph[crate_id].display_name.as_deref().unwrap_or_default().to_string();
38 38
39 cb(PrimeCachesProgress::StartedOnCrate { 39 cb(PrimeCachesProgress::StartedOnCrate {
40 on_crate: crate_name, 40 on_crate: crate_name,
41 n_done: i, 41 n_done: i,
42 n_total: topo.len(), 42 n_total: topo.len(),
43 }); 43 });
44 db.crate_def_map(*krate); 44 db.crate_def_map(crate_id);
45 db.import_map(crate_id);
45 } 46 }
46} 47}