mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Update salsa
This commit is contained in:
parent
86c534f244
commit
cda9668289
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1379,9 +1379,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "salsa"
|
||||
version = "0.17.0-pre.1"
|
||||
version = "0.17.0-pre.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58038261ea8cd5a7730c4d8c97a22063d7c7eb1c2809e55c3c15f0a5903e5582"
|
||||
checksum = "9b223dccb46c32753144d0b51290da7230bb4aedcd8379d6b4c9a474c18bf17a"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
"indexmap",
|
||||
@ -1396,9 +1396,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "salsa-macros"
|
||||
version = "0.17.0-pre.1"
|
||||
version = "0.17.0-pre.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e2fc060627fa5d44bffac98f6089b9497779e2deccc26687f60adc2638e32fb"
|
||||
checksum = "ac6c2e352df550bf019da7b16164ed2f7fa107c39653d1311d1bba42d1582ff7"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
|
@ -9,7 +9,7 @@ edition = "2018"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
salsa = "0.17.0-pre.1"
|
||||
salsa = "0.17.0-pre.2"
|
||||
rustc-hash = "1.1.0"
|
||||
|
||||
syntax = { path = "../syntax", version = "0.0.0" }
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use base_db::{salsa::SweepStrategy, SourceDatabaseExt};
|
||||
use base_db::SourceDatabaseExt;
|
||||
|
||||
use crate::{AdtId, ModuleDefId};
|
||||
|
||||
@ -199,8 +199,7 @@ pub type Ty = ();
|
||||
}
|
||||
|
||||
// Delete the parse tree.
|
||||
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
|
||||
base_db::ParseQuery.in_db(&db).sweep(sweep);
|
||||
base_db::ParseQuery.in_db(&db).purge();
|
||||
|
||||
{
|
||||
let events = db.log_executed(|| {
|
||||
|
@ -160,9 +160,6 @@ impl AnalysisHost {
|
||||
self.db.apply_change(change)
|
||||
}
|
||||
|
||||
pub fn collect_garbage(&mut self) {
|
||||
self.db.collect_garbage();
|
||||
}
|
||||
/// NB: this clears the database
|
||||
pub fn per_query_memory_usage(&mut self) -> Vec<(String, profile::Bytes)> {
|
||||
self.db.per_query_memory_usage()
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use base_db::{
|
||||
salsa::{Database, Durability, SweepStrategy},
|
||||
salsa::{Database, Durability},
|
||||
Change, SourceRootId,
|
||||
};
|
||||
use profile::{memory_usage, Bytes};
|
||||
@ -38,32 +38,6 @@ impl RootDatabase {
|
||||
change.apply(self);
|
||||
}
|
||||
|
||||
pub fn collect_garbage(&mut self) {
|
||||
if cfg!(target_arch = "wasm32") {
|
||||
return;
|
||||
}
|
||||
|
||||
let _p = profile::span("RootDatabase::collect_garbage");
|
||||
|
||||
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
|
||||
|
||||
base_db::ParseQuery.in_db(self).sweep(sweep);
|
||||
hir::db::ParseMacroExpansionQuery.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::MacroArgTextQuery).sweep(sweep);
|
||||
// self.query(hir::db::MacroExpandQuery).sweep(sweep);
|
||||
|
||||
hir::db::AstIdMapQuery.in_db(self).sweep(sweep);
|
||||
|
||||
hir::db::BodyWithSourceMapQuery.in_db(self).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.
|
||||
@ -76,32 +50,17 @@ impl RootDatabase {
|
||||
// image::https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif[]
|
||||
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 {
|
||||
macro_rules! purge_each_query {
|
||||
($($q:path)*) => {$(
|
||||
let before = memory_usage().allocated;
|
||||
$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;
|
||||
$q.in_db(self).sweep(sweep.discard_everything());
|
||||
let after = memory_usage().allocated;
|
||||
let q: $q = Default::default();
|
||||
let name = format!("{:?} (deps)", q);
|
||||
acc.push((name, before - after));
|
||||
|
||||
let before = memory_usage().allocated;
|
||||
$q.in_db(self).purge();
|
||||
let after = memory_usage().allocated;
|
||||
let q: $q = Default::default();
|
||||
let name = format!("{:?} (purge)", q);
|
||||
let name = format!("{:?}", q);
|
||||
acc.push((name, before - after));
|
||||
)*}
|
||||
}
|
||||
sweep_each_query![
|
||||
purge_each_query![
|
||||
// SourceDatabase
|
||||
base_db::ParseQuery
|
||||
base_db::CrateGraphQuery
|
||||
@ -119,6 +78,7 @@ impl RootDatabase {
|
||||
hir::db::ParseMacroExpansionQuery
|
||||
hir::db::MacroExpandQuery
|
||||
hir::db::HygieneFrameQuery
|
||||
hir::db::InternMacroQuery
|
||||
|
||||
// DefDatabase
|
||||
hir::db::FileItemTreeQuery
|
||||
@ -174,6 +134,7 @@ impl RootDatabase {
|
||||
hir::db::InternClosureQuery
|
||||
hir::db::AssociatedTyValueQuery
|
||||
hir::db::TraitSolveQueryQuery
|
||||
hir::db::InternTypeParamIdQuery
|
||||
|
||||
// SymbolsDatabase
|
||||
crate::symbol_index::FileSymbolsQuery
|
||||
@ -183,17 +144,6 @@ 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.salsa_runtime_mut().synthetic_write(Durability::HIGH);
|
||||
|
||||
sweep_each_query![
|
||||
// AstDatabase
|
||||
hir::db::InternMacroQuery
|
||||
|
||||
// InternDatabase
|
||||
hir::db::InternFunctionQuery
|
||||
@ -205,9 +155,6 @@ impl RootDatabase {
|
||||
hir::db::InternTraitQuery
|
||||
hir::db::InternTypeAliasQuery
|
||||
hir::db::InternImplQuery
|
||||
|
||||
// HirDatabase
|
||||
hir::db::InternTypeParamIdQuery
|
||||
];
|
||||
|
||||
acc.sort_by_key(|it| std::cmp::Reverse(it.1));
|
||||
|
Loading…
Reference in New Issue
Block a user