Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions crates/ra_ide_db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand Down
18 changes: 14 additions & 4 deletions crates/rust-analyzer/src/cli/analysis_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,22 @@ pub fn analysis_stats(
println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage());

if memory_usage {
for (name, bytes) in host.per_query_memory_usage() {
println!("{:>8} {}", bytes, name)
}
let mut mem = host.per_query_memory_usage();

let before = ra_prof::memory_usage();
drop(vfs);
let vfs = before.allocated - ra_prof::memory_usage().allocated;
mem.push(("VFS".into(), vfs));

let before = ra_prof::memory_usage();
drop(host);
println!("leftover: {}", before.allocated - ra_prof::memory_usage().allocated)
mem.push(("Unaccounted".into(), before.allocated - ra_prof::memory_usage().allocated));

mem.push(("Remaining".into(), ra_prof::memory_usage().allocated));

for (name, bytes) in mem {
println!("{:>8} {}", bytes, name)
}
}

Ok(())
Expand Down