diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-03 13:25:37 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-03 13:25:37 +0000 |
commit | 15d94cbffcb07fa910d715b2acef88109ae24d39 (patch) | |
tree | 0b4d2b1afcb919b50dd16efc4448c18eb39a9f16 /crates | |
parent | e423cfe383a4a1f9f0b5459810587d50bf2a2b2d (diff) | |
parent | 2e2e4435605b8fdabb36f018c2d6cba1fd0069b8 (diff) |
Merge #2731
2731: Split `crate_def_map` into two methods r=matklad a=michalt
This change:
- introduces `compute_crate_def_map` query and renames
`CrateDefMap::crate_def_map_query` for consistency,
- annotates `crate_def_map` as `salsa::transparent` and adds a
top-level `crate_def_map` wrapper function around that starts the
profiler and immediately calls into `compute_crate_def_map` query.
This allows us to better understand where we spent the time, in
particular, how much is spent in the recomputaiton and how much in
salsa.
Example output (where we don't actually re-compute anything, but the
query still takes a non-trivial amount of time):
```
211ms - handle_inlay_hints
150ms - get_inlay_hints
150ms - SourceAnalyzer::new
65ms - def_with_body_from_child_node
65ms - analyze_container
65ms - analyze_container
65ms - Module::from_definition
65ms - Module::from_file
65ms - crate_def_map
1ms - parse_macro_query (6 calls)
0ms - raw_items_query (1 calls)
64ms - ???
```
Signed-off-by: Michal Terepeta <[email protected]>
Co-authored-by: Michal Terepeta <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/db.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/db.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/change.rs | 2 |
4 files changed, 18 insertions, 9 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index f5ffd64fa..0af4a2868 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | pub use hir_def::db::{ | 3 | pub use hir_def::db::{ |
4 | BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery, | 4 | BodyQuery, BodyWithSourceMapQuery, ComputeCrateDefMapQuery, ConstDataQuery, |
5 | DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery, | 5 | CrateLangItemsQuery, DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, |
6 | FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage, | 6 | ExprScopesQuery, FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, |
7 | LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, StaticDataQuery, StructDataQuery, | 7 | InternDatabaseStorage, LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, StaticDataQuery, |
8 | TraitDataQuery, TypeAliasDataQuery, | 8 | StructDataQuery, TraitDataQuery, TypeAliasDataQuery, |
9 | }; | 9 | }; |
10 | pub use hir_expand::db::{ | 10 | pub use hir_expand::db::{ |
11 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, | 11 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, |
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index c55fd4111..da273eb11 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -3,6 +3,7 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use hir_expand::{db::AstDatabase, HirFileId}; | 4 | use hir_expand::{db::AstDatabase, HirFileId}; |
5 | use ra_db::{salsa, CrateId, SourceDatabase}; | 5 | use ra_db::{salsa, CrateId, SourceDatabase}; |
6 | use ra_prof::profile; | ||
6 | use ra_syntax::SmolStr; | 7 | use ra_syntax::SmolStr; |
7 | 8 | ||
8 | use crate::{ | 9 | use crate::{ |
@@ -46,9 +47,12 @@ pub trait DefDatabase: InternDatabase + AstDatabase { | |||
46 | #[salsa::invoke(RawItems::raw_items_query)] | 47 | #[salsa::invoke(RawItems::raw_items_query)] |
47 | fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>; | 48 | fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>; |
48 | 49 | ||
49 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] | 50 | #[salsa::transparent] |
50 | fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>; | 51 | fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>; |
51 | 52 | ||
53 | #[salsa::invoke(CrateDefMap::compute_crate_def_map_query)] | ||
54 | fn compute_crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>; | ||
55 | |||
52 | #[salsa::invoke(StructData::struct_data_query)] | 56 | #[salsa::invoke(StructData::struct_data_query)] |
53 | fn struct_data(&self, id: StructId) -> Arc<StructData>; | 57 | fn struct_data(&self, id: StructId) -> Arc<StructData>; |
54 | #[salsa::invoke(StructData::union_data_query)] | 58 | #[salsa::invoke(StructData::union_data_query)] |
@@ -104,3 +108,8 @@ pub trait DefDatabase: InternDatabase + AstDatabase { | |||
104 | #[salsa::invoke(Documentation::documentation_query)] | 108 | #[salsa::invoke(Documentation::documentation_query)] |
105 | fn documentation(&self, def: AttrDefId) -> Option<Documentation>; | 109 | fn documentation(&self, def: AttrDefId) -> Option<Documentation>; |
106 | } | 110 | } |
111 | |||
112 | fn crate_def_map(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | ||
113 | let _p = profile("crate_def_map"); | ||
114 | db.compute_crate_def_map(krate) | ||
115 | } | ||
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 5d4ca73a3..4d210eab1 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -172,13 +172,13 @@ pub struct ModuleData { | |||
172 | } | 172 | } |
173 | 173 | ||
174 | impl CrateDefMap { | 174 | impl CrateDefMap { |
175 | pub(crate) fn crate_def_map_query( | 175 | pub(crate) fn compute_crate_def_map_query( |
176 | // Note that this doesn't have `+ AstDatabase`! | 176 | // Note that this doesn't have `+ AstDatabase`! |
177 | // This gurantess that `CrateDefMap` is stable across reparses. | 177 | // This gurantess that `CrateDefMap` is stable across reparses. |
178 | db: &impl DefDatabase, | 178 | db: &impl DefDatabase, |
179 | krate: CrateId, | 179 | krate: CrateId, |
180 | ) -> Arc<CrateDefMap> { | 180 | ) -> Arc<CrateDefMap> { |
181 | let _p = profile("crate_def_map_query"); | 181 | let _p = profile("compute_crate_def_map"); |
182 | let def_map = { | 182 | let def_map = { |
183 | let crate_graph = db.crate_graph(); | 183 | let crate_graph = db.crate_graph(); |
184 | let edition = crate_graph.edition(krate); | 184 | let edition = crate_graph.edition(krate); |
diff --git a/crates/ra_ide/src/change.rs b/crates/ra_ide/src/change.rs index 387a9cafb..4585bf522 100644 --- a/crates/ra_ide/src/change.rs +++ b/crates/ra_ide/src/change.rs | |||
@@ -309,7 +309,7 @@ impl RootDatabase { | |||
309 | hir::db::EnumDataQuery | 309 | hir::db::EnumDataQuery |
310 | hir::db::TraitDataQuery | 310 | hir::db::TraitDataQuery |
311 | hir::db::RawItemsQuery | 311 | hir::db::RawItemsQuery |
312 | hir::db::CrateDefMapQuery | 312 | hir::db::ComputeCrateDefMapQuery |
313 | hir::db::GenericParamsQuery | 313 | hir::db::GenericParamsQuery |
314 | hir::db::FunctionDataQuery | 314 | hir::db::FunctionDataQuery |
315 | hir::db::TypeAliasDataQuery | 315 | hir::db::TypeAliasDataQuery |