Use salsa's purge to account for all memory

This commit is contained in:
Aleksey Kladov 2020-07-22 18:44:40 +02:00
parent 2ad29eb231
commit edd4a83ee3
4 changed files with 35 additions and 20 deletions

20
Cargo.lock generated
View file

@ -318,9 +318,9 @@ dependencies = [
[[package]] [[package]]
name = "filetime" name = "filetime"
version = "0.2.11" version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e500da2fab70bdc43f8f0e0b350a227f31c72311c56aba48f01d5cd62bb0345b" checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -1371,9 +1371,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]] [[package]]
name = "salsa" name = "salsa"
version = "0.15.1" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4cdc109fcc9e9450c7ef47fb7474e99bffd51799da03ed0a6c7f0e2cb3848a6" checksum = "9ab29056d4fb4048a5f0d169c9b6e5526160c9ec37aded5a6879c2c9c445a8e4"
dependencies = [ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"indexmap", "indexmap",
@ -1388,9 +1388,9 @@ dependencies = [
[[package]] [[package]]
name = "salsa-macros" name = "salsa-macros"
version = "0.15.0" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c280ac85b15ac214b86ac4b407626a48e6a1c4f90769a582fec74aa57942b9f" checksum = "a1c3aec007c63c4ed4cd7a018529fb0b5575c4562575fc6a40d6cd2ae0b792ef"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@ -1533,9 +1533,9 @@ version = "0.1.0"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.36" version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1644,9 +1644,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-core" name = "tracing-core"
version = "0.1.12" version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2734b5a028fa697686f16c6d18c2c6a3c7e41513f9a213abb6754c4acb3c8d7" checksum = "d593f98af59ebc017c0648f0117525db358745a8894a8d684e185ba3f45954f9"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
] ]

View file

@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
doctest = false doctest = false
[dependencies] [dependencies]
salsa = "0.15.0" salsa = "0.15.2"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
ra_syntax = { path = "../ra_syntax" } ra_syntax = { path = "../ra_syntax" }

View file

@ -13,14 +13,7 @@ pub use hir_expand::db::{
AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery, AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery,
MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery, MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery,
}; };
pub use hir_ty::db::{ pub use hir_ty::db::*;
AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, FieldTypesQuery,
GenericDefaultsQuery, GenericPredicatesForParamQuery, GenericPredicatesQuery, HirDatabase,
HirDatabaseStorage, ImplDatumQuery, ImplSelfTyQuery, ImplTraitQuery, InferQueryQuery,
InherentImplsInCrateQuery, InternTypeParamIdQuery, ReturnTypeImplTraitsQuery, StructDatumQuery,
TraitDatumQuery, TraitImplsInCrateQuery, TraitImplsInDepsQuery, TraitSolveQuery, TyQuery,
ValueTyQuery,
};
#[test] #[test]
fn hir_database_is_object_safe() { fn hir_database_is_object_safe() {

View file

@ -190,11 +190,24 @@ impl RootDatabase {
let q: $q = Default::default(); let q: $q = Default::default();
let name = format!("{:?} (deps)", q); let name = format!("{:?} (deps)", q);
acc.push((name, before - after)); 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);
acc.push((name, before - after));
)*} )*}
} }
sweep_each_query![ sweep_each_query![
// SourceDatabase // SourceDatabase
ra_db::ParseQuery ra_db::ParseQuery
ra_db::CrateGraphQuery
// SourceDatabaseExt
ra_db::FileTextQuery
ra_db::FileSourceRootQuery
ra_db::SourceRootQuery
ra_db::SourceRootCratesQuery ra_db::SourceRootCratesQuery
// AstDatabase // AstDatabase
@ -242,15 +255,24 @@ impl RootDatabase {
hir::db::TraitImplsInCrateQuery hir::db::TraitImplsInCrateQuery
hir::db::TraitImplsInDepsQuery hir::db::TraitImplsInDepsQuery
hir::db::AssociatedTyDataQuery hir::db::AssociatedTyDataQuery
hir::db::AssociatedTyDataQuery
hir::db::TraitDatumQuery hir::db::TraitDatumQuery
hir::db::StructDatumQuery hir::db::StructDatumQuery
hir::db::ImplDatumQuery hir::db::ImplDatumQuery
hir::db::FnDefDatumQuery
hir::db::ReturnTypeImplTraitsQuery
hir::db::InternCallableDefQuery
hir::db::InternTypeParamIdQuery
hir::db::InternImplTraitIdQuery
hir::db::InternClosureQuery
hir::db::AssociatedTyValueQuery hir::db::AssociatedTyValueQuery
hir::db::TraitSolveQuery hir::db::TraitSolveQuery
hir::db::ReturnTypeImplTraitsQuery
// SymbolsDatabase // SymbolsDatabase
crate::symbol_index::FileSymbolsQuery crate::symbol_index::FileSymbolsQuery
crate::symbol_index::LibrarySymbolsQuery
crate::symbol_index::LocalRootsQuery
crate::symbol_index::LibraryRootsQuery
// LineIndexDatabase // LineIndexDatabase
crate::LineIndexQuery crate::LineIndexQuery