From cda9668289868239b87954b44296f14842679490 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 6 Oct 2021 22:42:54 +0200 Subject: [PATCH] Update salsa --- Cargo.lock | 8 +-- crates/base_db/Cargo.toml | 2 +- .../hir_def/src/nameres/tests/incremental.rs | 5 +- crates/ide/src/lib.rs | 3 - crates/ide_db/src/apply_change.rs | 65 ++----------------- 5 files changed, 13 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1058c02c7..ddd83471e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1379,9 +1379,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "salsa" -version = "0.17.0-pre.1" +version = "0.17.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58038261ea8cd5a7730c4d8c97a22063d7c7eb1c2809e55c3c15f0a5903e5582" +checksum = "9b223dccb46c32753144d0b51290da7230bb4aedcd8379d6b4c9a474c18bf17a" dependencies = [ "crossbeam-utils", "indexmap", @@ -1396,9 +1396,9 @@ dependencies = [ [[package]] name = "salsa-macros" -version = "0.17.0-pre.1" +version = "0.17.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e2fc060627fa5d44bffac98f6089b9497779e2deccc26687f60adc2638e32fb" +checksum = "ac6c2e352df550bf019da7b16164ed2f7fa107c39653d1311d1bba42d1582ff7" dependencies = [ "heck", "proc-macro2", diff --git a/crates/base_db/Cargo.toml b/crates/base_db/Cargo.toml index b43e5efb2a..15ada0f34a 100644 --- a/crates/base_db/Cargo.toml +++ b/crates/base_db/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" doctest = false [dependencies] -salsa = "0.17.0-pre.1" +salsa = "0.17.0-pre.2" rustc-hash = "1.1.0" syntax = { path = "../syntax", version = "0.0.0" } diff --git a/crates/hir_def/src/nameres/tests/incremental.rs b/crates/hir_def/src/nameres/tests/incremental.rs index 7bf152e26c..b2828831a1 100644 --- a/crates/hir_def/src/nameres/tests/incremental.rs +++ b/crates/hir_def/src/nameres/tests/incremental.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use base_db::{salsa::SweepStrategy, SourceDatabaseExt}; +use base_db::SourceDatabaseExt; use crate::{AdtId, ModuleDefId}; @@ -199,8 +199,7 @@ pub type Ty = (); } // Delete the parse tree. - let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); - base_db::ParseQuery.in_db(&db).sweep(sweep); + base_db::ParseQuery.in_db(&db).purge(); { let events = db.log_executed(|| { diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 5c47227990..92c526cfce 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -160,9 +160,6 @@ impl AnalysisHost { self.db.apply_change(change) } - pub fn collect_garbage(&mut self) { - self.db.collect_garbage(); - } /// NB: this clears the database pub fn per_query_memory_usage(&mut self) -> Vec<(String, profile::Bytes)> { self.db.per_query_memory_usage() diff --git a/crates/ide_db/src/apply_change.rs b/crates/ide_db/src/apply_change.rs index d9bf7c9cc7..0df0b0035d 100644 --- a/crates/ide_db/src/apply_change.rs +++ b/crates/ide_db/src/apply_change.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use base_db::{ - salsa::{Database, Durability, SweepStrategy}, + salsa::{Database, Durability}, Change, SourceRootId, }; use profile::{memory_usage, Bytes}; @@ -38,32 +38,6 @@ impl RootDatabase { change.apply(self); } - pub fn collect_garbage(&mut self) { - if cfg!(target_arch = "wasm32") { - return; - } - - let _p = profile::span("RootDatabase::collect_garbage"); - - let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); - - base_db::ParseQuery.in_db(self).sweep(sweep); - hir::db::ParseMacroExpansionQuery.in_db(self).sweep(sweep); - - // Macros do take significant space, but less then the syntax trees - // self.query(hir::db::MacroDefQuery).sweep(sweep); - // self.query(hir::db::MacroArgTextQuery).sweep(sweep); - // self.query(hir::db::MacroExpandQuery).sweep(sweep); - - hir::db::AstIdMapQuery.in_db(self).sweep(sweep); - - hir::db::BodyWithSourceMapQuery.in_db(self).sweep(sweep); - - hir::db::ExprScopesQuery.in_db(self).sweep(sweep); - hir::db::InferQueryQuery.in_db(self).sweep(sweep); - hir::db::BodyQuery.in_db(self).sweep(sweep); - } - // Feature: Memory Usage // // Clears rust-analyzer's internal database and prints memory usage statistics. @@ -76,32 +50,17 @@ impl RootDatabase { // image::https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif[] pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> { let mut acc: Vec<(String, Bytes)> = vec![]; - let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); - macro_rules! sweep_each_query { + macro_rules! purge_each_query { ($($q:path)*) => {$( - let before = memory_usage().allocated; - $q.in_db(self).sweep(sweep); - let after = memory_usage().allocated; - let q: $q = Default::default(); - let name = format!("{:?}", q); - acc.push((name, before - after)); - - let before = memory_usage().allocated; - $q.in_db(self).sweep(sweep.discard_everything()); - let after = memory_usage().allocated; - let q: $q = Default::default(); - let name = format!("{:?} (deps)", q); - acc.push((name, before - after)); - let before = memory_usage().allocated; $q.in_db(self).purge(); let after = memory_usage().allocated; let q: $q = Default::default(); - let name = format!("{:?} (purge)", q); + let name = format!("{:?}", q); acc.push((name, before - after)); )*} } - sweep_each_query![ + purge_each_query![ // SourceDatabase base_db::ParseQuery base_db::CrateGraphQuery @@ -119,6 +78,7 @@ impl RootDatabase { hir::db::ParseMacroExpansionQuery hir::db::MacroExpandQuery hir::db::HygieneFrameQuery + hir::db::InternMacroQuery // DefDatabase hir::db::FileItemTreeQuery @@ -174,6 +134,7 @@ impl RootDatabase { hir::db::InternClosureQuery hir::db::AssociatedTyValueQuery hir::db::TraitSolveQueryQuery + hir::db::InternTypeParamIdQuery // SymbolsDatabase crate::symbol_index::FileSymbolsQuery @@ -183,17 +144,6 @@ impl RootDatabase { // LineIndexDatabase crate::LineIndexQuery - ]; - - // To collect interned data, we need to bump the revision counter by performing a synthetic - // write. - // We do this after collecting the non-interned queries to correctly attribute memory used - // by interned data. - self.salsa_runtime_mut().synthetic_write(Durability::HIGH); - - sweep_each_query![ - // AstDatabase - hir::db::InternMacroQuery // InternDatabase hir::db::InternFunctionQuery @@ -205,9 +155,6 @@ impl RootDatabase { hir::db::InternTraitQuery hir::db::InternTypeAliasQuery hir::db::InternImplQuery - - // HirDatabase - hir::db::InternTypeParamIdQuery ]; acc.sort_by_key(|it| std::cmp::Reverse(it.1));