From 6bde542a39fe63298a31b838e59705797ed8a2cf Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 1 Jul 2020 17:15:20 +0200 Subject: Split `CrateImplDefs` in inherent and trait impls This makes the intention of inherent vs. trait impls somewhat more clear and also fixes (?) an issue where trait impls with an unresolved trait were added as inherent impls instead (hence the test changes). --- crates/ra_ide_db/src/change.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index b507000f2..dbe6eacc5 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -243,8 +243,9 @@ impl RootDatabase { hir::db::GenericPredicatesForParamQuery hir::db::GenericPredicatesQuery hir::db::GenericDefaultsQuery - hir::db::ImplsInCrateQuery - hir::db::ImplsFromDepsQuery + hir::db::InherentImplsInCrateQuery + hir::db::TraitImplsInCrateQuery + hir::db::TraitImplsInDepsQuery hir::db::InternTypeCtorQuery hir::db::InternTypeParamIdQuery hir::db::InternChalkImplQuery -- cgit v1.2.3 From 93d0ac7fa0a5a9548ac07e22ac14eee46550172c Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 3 Jul 2020 17:12:29 +0200 Subject: Fix memory usage accounting for interned queries --- crates/ra_ide_db/src/change.rs | 47 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index dbe6eacc5..2504d7a33 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -191,12 +191,10 @@ impl RootDatabase { // AstDatabase hir::db::AstIdMapQuery - hir::db::InternMacroQuery hir::db::MacroArgQuery hir::db::MacroDefQuery hir::db::ParseMacroQuery hir::db::MacroExpandQuery - hir::db::InternEagerExpansionQuery // DefDatabase hir::db::ItemTreeQuery @@ -221,17 +219,6 @@ impl RootDatabase { hir::db::DocumentationQuery hir::db::ImportMapQuery - // InternDatabase - hir::db::InternFunctionQuery - hir::db::InternStructQuery - hir::db::InternUnionQuery - hir::db::InternEnumQuery - hir::db::InternConstQuery - hir::db::InternStaticQuery - hir::db::InternTraitQuery - hir::db::InternTypeAliasQuery - hir::db::InternImplQuery - // HirDatabase hir::db::InferQueryQuery hir::db::TyQuery @@ -246,10 +233,6 @@ impl RootDatabase { hir::db::InherentImplsInCrateQuery hir::db::TraitImplsInCrateQuery hir::db::TraitImplsInDepsQuery - hir::db::InternTypeCtorQuery - hir::db::InternTypeParamIdQuery - hir::db::InternChalkImplQuery - hir::db::InternAssocTyValueQuery hir::db::AssociatedTyDataQuery hir::db::TraitDatumQuery hir::db::StructDatumQuery @@ -264,6 +247,36 @@ 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.runtime.synthetic_write(Durability::HIGH); + + sweep_each_query![ + // AstDatabase + hir::db::InternMacroQuery + hir::db::InternEagerExpansionQuery + + // InternDatabase + hir::db::InternFunctionQuery + hir::db::InternStructQuery + hir::db::InternUnionQuery + hir::db::InternEnumQuery + hir::db::InternConstQuery + hir::db::InternStaticQuery + hir::db::InternTraitQuery + hir::db::InternTypeAliasQuery + hir::db::InternImplQuery + + // HirDatabase + hir::db::InternTypeCtorQuery + hir::db::InternTypeParamIdQuery + hir::db::InternChalkImplQuery + hir::db::InternAssocTyValueQuery + ]; + acc.sort_by_key(|it| std::cmp::Reverse(it.1)); acc } -- cgit v1.2.3 From 4bbc385277bcab509c321b1374f72f1ef19d7750 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Jul 2020 10:14:48 +0200 Subject: Switch to fully dynamically dispatched salsa This improves compile times quite a bit --- crates/ra_ide_db/src/change.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index 2504d7a33..d8da3f949 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -147,21 +147,21 @@ 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); + ra_db::ParseQuery.in_db(self).sweep(sweep); + hir::db::ParseMacroQuery.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::MacroArgQuery).sweep(sweep); // self.query(hir::db::MacroExpandQuery).sweep(sweep); - self.query(hir::db::AstIdMapQuery).sweep(sweep); + hir::db::AstIdMapQuery.in_db(self).sweep(sweep); - self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep); + hir::db::BodyWithSourceMapQuery.in_db(self).sweep(sweep); - self.query(hir::db::ExprScopesQuery).sweep(sweep); - self.query(hir::db::InferQueryQuery).sweep(sweep); - self.query(hir::db::BodyQuery).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); } pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> { @@ -170,14 +170,14 @@ impl RootDatabase { macro_rules! sweep_each_query { ($($q:path)*) => {$( let before = memory_usage().allocated; - self.query($q).sweep(sweep); + $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; - self.query($q).sweep(sweep.discard_everything()); + $q.in_db(self).sweep(sweep.discard_everything()); let after = memory_usage().allocated; let q: $q = Default::default(); let name = format!("{:?} (deps)", q); @@ -252,7 +252,7 @@ impl RootDatabase { // write. // We do this after collecting the non-interned queries to correctly attribute memory used // by interned data. - self.runtime.synthetic_write(Durability::HIGH); + self.salsa_runtime_mut().synthetic_write(Durability::HIGH); sweep_each_query![ // AstDatabase -- cgit v1.2.3 From f44c4b61e131284287b24dea6da6324cbe9cb252 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 7 Jul 2020 12:10:14 +0200 Subject: Add a command to compute memory usage statistics --- crates/ra_ide_db/src/change.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index d8da3f949..84c6f40ff 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -164,6 +164,15 @@ impl RootDatabase { hir::db::BodyQuery.in_db(self).sweep(sweep); } + // Feature: Memory Usage + // + // Clears rust-analyzer's internal database and prints memory usage statistics. + // + // |=== + // | Editor | Action Name + // + // | VS Code | **Rust Analyzer: Memory Usage (Clears Database)** + // |=== 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(); -- cgit v1.2.3 From dab7f3d2c6cd035f446fbdcda2442954da4afd3a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 8 Jul 2020 19:09:42 +0200 Subject: Remove relative_path dependency --- crates/ra_ide_db/src/change.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index 84c6f40ff..d1a255dcf 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -5,8 +5,7 @@ use std::{fmt, sync::Arc, time}; use ra_db::{ salsa::{Database, Durability, SweepStrategy}, - CrateGraph, FileId, RelativePathBuf, SourceDatabase, SourceDatabaseExt, SourceRoot, - SourceRootId, + CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId, }; use ra_prof::{memory_usage, profile, Bytes}; use rustc_hash::FxHashSet; @@ -57,14 +56,14 @@ impl AnalysisChange { #[derive(Debug)] struct AddFile { file_id: FileId, - path: RelativePathBuf, + path: String, text: Arc, } #[derive(Debug)] struct RemoveFile { file_id: FileId, - path: RelativePathBuf, + path: String, } #[derive(Default)] -- cgit v1.2.3 From a48843a16a2306399f2f6a78c69d9192a6480c88 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 12 Jul 2020 15:26:02 +0200 Subject: Use Chalk closure support --- crates/ra_ide_db/src/change.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index d1a255dcf..d40cfeb02 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -281,8 +281,6 @@ impl RootDatabase { // HirDatabase hir::db::InternTypeCtorQuery hir::db::InternTypeParamIdQuery - hir::db::InternChalkImplQuery - hir::db::InternAssocTyValueQuery ]; acc.sort_by_key(|it| std::cmp::Reverse(it.1)); -- cgit v1.2.3 From 20770044631fd0c21caa12f9bc87489ea6c848ee Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 15 Jul 2020 21:47:45 +0200 Subject: Remove TypeCtor interning Our TypeCtor and Chalk's TypeName match now! --- crates/ra_ide_db/src/change.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index d40cfeb02..a1bb3043b 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -279,7 +279,6 @@ impl RootDatabase { hir::db::InternImplQuery // HirDatabase - hir::db::InternTypeCtorQuery hir::db::InternTypeParamIdQuery ]; -- cgit v1.2.3 From cb958cf5fec8b051d16833ac0890cace379ad765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Wed, 22 Jul 2020 21:50:37 +0300 Subject: Store macro invocation parameters as text instead of tt --- crates/ra_ide_db/src/change.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide_db/src/change.rs') diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index a1bb3043b..32d9a8d1f 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -151,7 +151,7 @@ impl RootDatabase { // Macros do take significant space, but less then the syntax trees // self.query(hir::db::MacroDefQuery).sweep(sweep); - // self.query(hir::db::MacroArgQuery).sweep(sweep); + // self.query(hir::db::MacroArgTextQuery).sweep(sweep); // self.query(hir::db::MacroExpandQuery).sweep(sweep); hir::db::AstIdMapQuery.in_db(self).sweep(sweep); @@ -199,7 +199,7 @@ impl RootDatabase { // AstDatabase hir::db::AstIdMapQuery - hir::db::MacroArgQuery + hir::db::MacroArgTextQuery hir::db::MacroDefQuery hir::db::ParseMacroQuery hir::db::MacroExpandQuery -- cgit v1.2.3