diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-12 11:36:47 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-12 11:36:47 +0100 |
commit | 03645c55761f8c9345ee3837a6010e65e7a80179 (patch) | |
tree | 9c24cb112429b0334762063e71a65a1907386e59 /crates/ra_batch | |
parent | 6296f51678843c96a4ab1f1e6784b6d69222e072 (diff) | |
parent | fed52706def9a9f5d33edc7dd9848a02ae475ba5 (diff) |
Merge #1382
1382: use salsa's LRU for syntax trees r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_batch')
-rw-r--r-- | crates/ra_batch/src/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index a445dcb4d..c59821f44 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs | |||
@@ -7,7 +7,7 @@ use std::collections::HashSet; | |||
7 | use rustc_hash::FxHashMap; | 7 | use rustc_hash::FxHashMap; |
8 | 8 | ||
9 | use ra_db::{ | 9 | use ra_db::{ |
10 | CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa, | 10 | CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa::{self, Database}, |
11 | }; | 11 | }; |
12 | use ra_hir::db; | 12 | use ra_hir::db; |
13 | use ra_project_model::ProjectWorkspace; | 13 | use ra_project_model::ProjectWorkspace; |
@@ -43,6 +43,12 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId { | |||
43 | impl BatchDatabase { | 43 | impl BatchDatabase { |
44 | pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase { | 44 | pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase { |
45 | let mut db = BatchDatabase { runtime: salsa::Runtime::default() }; | 45 | let mut db = BatchDatabase { runtime: salsa::Runtime::default() }; |
46 | let lru_cap = std::env::var("RA_LRU_CAP") | ||
47 | .ok() | ||
48 | .and_then(|it| it.parse::<usize>().ok()) | ||
49 | .unwrap_or(ra_db::DEFAULT_LRU_CAP); | ||
50 | db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_cap); | ||
51 | db.query_mut(ra_hir::db::ParseMacroQuery).set_lru_capacity(lru_cap); | ||
46 | db.set_crate_graph(Arc::new(crate_graph)); | 52 | db.set_crate_graph(Arc::new(crate_graph)); |
47 | 53 | ||
48 | // wait until Vfs has loaded all roots | 54 | // wait until Vfs has loaded all roots |