use salsa's LRU for syntax trees

This commit is contained in:
Aleksey Kladov 2019-06-07 09:50:32 +03:00
parent 80aa9d5f9f
commit fc2658b074
5 changed files with 11 additions and 7 deletions

7
Cargo.lock generated
View File

@ -1058,7 +1058,7 @@ dependencies = [
"ra_syntax 0.1.0",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]
@ -1478,11 +1478,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "salsa"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2125,7 +2126,7 @@ dependencies = [
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
"checksum salsa 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2208fabe493ad352dc4f544c482b39e9b9a2c1719d9aa4a0f5e828a61210956"
"checksum salsa 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2891cd628406e8a0ca714b827511de1bff76f796e3382cc72a3de732ccad5aea"
"checksum salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7f1e25ca2b995bdf032946174929d62156ffd57abd7ff88dc6f9bdeb5ac0c59"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"

View File

@ -7,7 +7,7 @@
use rustc_hash::FxHashMap;
use ra_db::{
CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa,
CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa::{self, Database},
};
use ra_hir::db;
use ra_project_model::ProjectWorkspace;
@ -43,6 +43,8 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
impl BatchDatabase {
pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase {
let mut db = BatchDatabase { runtime: salsa::Runtime::default() };
db.query_mut(ra_db::ParseQuery).set_lru_capacity(128);
db.query_mut(ra_hir::db::ParseMacroQuery).set_lru_capacity(128);
db.set_crate_graph(Arc::new(crate_graph));
// wait until Vfs has loaded all roots

View File

@ -5,7 +5,7 @@ version = "0.1.0"
authors = ["rust-analyzer developers"]
[dependencies]
salsa = "0.12.1"
salsa = "0.12.3"
relative-path = "0.4.0"
rustc-hash = "1.0"

View File

@ -225,7 +225,6 @@ pub(crate) fn collect_garbage(&mut self) {
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
self.query(ra_db::ParseQuery).sweep(sweep);
self.query(hir::db::ParseMacroQuery).sweep(sweep);
self.query(hir::db::MacroDefQuery).sweep(sweep);
self.query(hir::db::MacroArgQuery).sweep(sweep);

View File

@ -5,7 +5,7 @@
use ra_db::{
CheckCanceled, FileId, Canceled, SourceDatabase,
salsa,
salsa::{self, Database},
};
use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}};
@ -49,6 +49,8 @@ fn default() -> RootDatabase {
db.set_crate_graph(Default::default());
db.set_local_roots(Default::default());
db.set_library_roots(Default::default());
db.query_mut(ra_db::ParseQuery).set_lru_capacity(128);
db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(128);
db
}
}