From fc2658b0749b03f365a3f176582311efd2bc6462 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 7 Jun 2019 09:50:32 +0300 Subject: [PATCH] use salsa's LRU for syntax trees --- Cargo.lock | 7 ++++--- crates/ra_batch/src/lib.rs | 4 +++- crates/ra_db/Cargo.toml | 2 +- crates/ra_ide_api/src/change.rs | 1 - crates/ra_ide_api/src/db.rs | 4 +++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 579daecf18..2c1c7099e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index a445dcb4d4..02ea893065 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs @@ -7,7 +7,7 @@ use std::collections::HashSet; 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 diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 827855b2fb..f73dd739a4 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -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" diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index 247dc0feed..ce03a0f952 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs @@ -225,7 +225,6 @@ impl RootDatabase { 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); diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index d1a452ecb5..4f19b01c46 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs @@ -5,7 +5,7 @@ use std::{ use ra_db::{ CheckCanceled, FileId, Canceled, SourceDatabase, - salsa, + salsa::{self, Database}, }; use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; @@ -49,6 +49,8 @@ impl Default for 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 } }