Skip to content

Commit 93d0ac7

Browse files
author
Jonas Schievink
committed
Fix memory usage accounting for interned queries
1 parent 88a602f commit 93d0ac7

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

crates/ra_ide_db/src/change.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,10 @@ impl RootDatabase {
191191

192192
// AstDatabase
193193
hir::db::AstIdMapQuery
194-
hir::db::InternMacroQuery
195194
hir::db::MacroArgQuery
196195
hir::db::MacroDefQuery
197196
hir::db::ParseMacroQuery
198197
hir::db::MacroExpandQuery
199-
hir::db::InternEagerExpansionQuery
200198

201199
// DefDatabase
202200
hir::db::ItemTreeQuery
@@ -221,17 +219,6 @@ impl RootDatabase {
221219
hir::db::DocumentationQuery
222220
hir::db::ImportMapQuery
223221

224-
// InternDatabase
225-
hir::db::InternFunctionQuery
226-
hir::db::InternStructQuery
227-
hir::db::InternUnionQuery
228-
hir::db::InternEnumQuery
229-
hir::db::InternConstQuery
230-
hir::db::InternStaticQuery
231-
hir::db::InternTraitQuery
232-
hir::db::InternTypeAliasQuery
233-
hir::db::InternImplQuery
234-
235222
// HirDatabase
236223
hir::db::InferQueryQuery
237224
hir::db::TyQuery
@@ -246,10 +233,6 @@ impl RootDatabase {
246233
hir::db::InherentImplsInCrateQuery
247234
hir::db::TraitImplsInCrateQuery
248235
hir::db::TraitImplsInDepsQuery
249-
hir::db::InternTypeCtorQuery
250-
hir::db::InternTypeParamIdQuery
251-
hir::db::InternChalkImplQuery
252-
hir::db::InternAssocTyValueQuery
253236
hir::db::AssociatedTyDataQuery
254237
hir::db::TraitDatumQuery
255238
hir::db::StructDatumQuery
@@ -264,6 +247,36 @@ impl RootDatabase {
264247
// LineIndexDatabase
265248
crate::LineIndexQuery
266249
];
250+
251+
// To collect interned data, we need to bump the revision counter by performing a synthetic
252+
// write.
253+
// We do this after collecting the non-interned queries to correctly attribute memory used
254+
// by interned data.
255+
self.runtime.synthetic_write(Durability::HIGH);
256+
257+
sweep_each_query![
258+
// AstDatabase
259+
hir::db::InternMacroQuery
260+
hir::db::InternEagerExpansionQuery
261+
262+
// InternDatabase
263+
hir::db::InternFunctionQuery
264+
hir::db::InternStructQuery
265+
hir::db::InternUnionQuery
266+
hir::db::InternEnumQuery
267+
hir::db::InternConstQuery
268+
hir::db::InternStaticQuery
269+
hir::db::InternTraitQuery
270+
hir::db::InternTypeAliasQuery
271+
hir::db::InternImplQuery
272+
273+
// HirDatabase
274+
hir::db::InternTypeCtorQuery
275+
hir::db::InternTypeParamIdQuery
276+
hir::db::InternChalkImplQuery
277+
hir::db::InternAssocTyValueQuery
278+
];
279+
267280
acc.sort_by_key(|it| std::cmp::Reverse(it.1));
268281
acc
269282
}

0 commit comments

Comments
 (0)