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;
#[derive(Debug)]
struct AddFile {
file_id: FileId,
- path: RelativePathBuf,
+ path: String,
text: Arc<String>,
}
#[derive(Debug)]
struct RemoveFile {
file_id: FileId,
- path: RelativePathBuf,
+ path: String,
}
#[derive(Default)]
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);
}
+ // 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();
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);
// 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