mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
make LRU_CAP configurable for batch db
This commit is contained in:
parent
fc2658b074
commit
15668119de
3 changed files with 11 additions and 4 deletions
|
@ -43,8 +43,12 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
|
||||||
impl BatchDatabase {
|
impl BatchDatabase {
|
||||||
pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase {
|
pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase {
|
||||||
let mut db = BatchDatabase { runtime: salsa::Runtime::default() };
|
let mut db = BatchDatabase { runtime: salsa::Runtime::default() };
|
||||||
db.query_mut(ra_db::ParseQuery).set_lru_capacity(128);
|
let lru_cap = std::env::var("RA_LRU_CAP")
|
||||||
db.query_mut(ra_hir::db::ParseMacroQuery).set_lru_capacity(128);
|
.ok()
|
||||||
|
.and_then(|it| it.parse::<usize>().ok())
|
||||||
|
.unwrap_or(ra_db::DEFAULT_LRU_CAP);
|
||||||
|
db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_cap);
|
||||||
|
db.query_mut(ra_hir::db::ParseMacroQuery).set_lru_capacity(lru_cap);
|
||||||
db.set_crate_graph(Arc::new(crate_graph));
|
db.set_crate_graph(Arc::new(crate_graph));
|
||||||
|
|
||||||
// wait until Vfs has loaded all roots
|
// wait until Vfs has loaded all roots
|
||||||
|
|
|
@ -65,6 +65,8 @@ pub struct FileRange {
|
||||||
pub range: TextRange,
|
pub range: TextRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const DEFAULT_LRU_CAP: usize = 128;
|
||||||
|
|
||||||
/// Database which stores all significant input facts: source code and project
|
/// Database which stores all significant input facts: source code and project
|
||||||
/// model. Everything else in rust-analyzer is derived from these queries.
|
/// model. Everything else in rust-analyzer is derived from these queries.
|
||||||
#[salsa::query_group(SourceDatabaseStorage)]
|
#[salsa::query_group(SourceDatabaseStorage)]
|
||||||
|
|
|
@ -49,8 +49,9 @@ impl Default for RootDatabase {
|
||||||
db.set_crate_graph(Default::default());
|
db.set_crate_graph(Default::default());
|
||||||
db.set_local_roots(Default::default());
|
db.set_local_roots(Default::default());
|
||||||
db.set_library_roots(Default::default());
|
db.set_library_roots(Default::default());
|
||||||
db.query_mut(ra_db::ParseQuery).set_lru_capacity(128);
|
let lru_cap = ra_db::DEFAULT_LRU_CAP;
|
||||||
db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(128);
|
db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_cap);
|
||||||
|
db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_cap);
|
||||||
db
|
db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue