diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-03 16:58:46 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-03 16:58:46 +0100 |
commit | 0f68fed4a0701330e0296f6623567e5584f2f7ba (patch) | |
tree | 808d5eda0675d14f32af44ff206eca8bda976846 /crates | |
parent | dceec6176b49f886b94f1e149887fc9542702971 (diff) | |
parent | f01e7e3601423e176e16c66aebbe6aca541a5731 (diff) |
Merge #5209
5209: Fixes to memory usage stats r=matklad a=jonas-schievink
This brings the unaccounted memory down from 287mb to 250mb, and displays memory used by VFS and "other" allocations.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_db/src/change.rs | 47 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli/analysis_stats.rs | 18 |
2 files changed, 44 insertions, 21 deletions
diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index dbe6eacc5..2504d7a33 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs | |||
@@ -191,12 +191,10 @@ impl RootDatabase { | |||
191 | 191 | ||
192 | // AstDatabase | 192 | // AstDatabase |
193 | hir::db::AstIdMapQuery | 193 | hir::db::AstIdMapQuery |
194 | hir::db::InternMacroQuery | ||
195 | hir::db::MacroArgQuery | 194 | hir::db::MacroArgQuery |
196 | hir::db::MacroDefQuery | 195 | hir::db::MacroDefQuery |
197 | hir::db::ParseMacroQuery | 196 | hir::db::ParseMacroQuery |
198 | hir::db::MacroExpandQuery | 197 | hir::db::MacroExpandQuery |
199 | hir::db::InternEagerExpansionQuery | ||
200 | 198 | ||
201 | // DefDatabase | 199 | // DefDatabase |
202 | hir::db::ItemTreeQuery | 200 | hir::db::ItemTreeQuery |
@@ -221,17 +219,6 @@ impl RootDatabase { | |||
221 | hir::db::DocumentationQuery | 219 | hir::db::DocumentationQuery |
222 | hir::db::ImportMapQuery | 220 | hir::db::ImportMapQuery |
223 | 221 | ||
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 | |||
235 | // HirDatabase | 222 | // HirDatabase |
236 | hir::db::InferQueryQuery | 223 | hir::db::InferQueryQuery |
237 | hir::db::TyQuery | 224 | hir::db::TyQuery |
@@ -246,10 +233,6 @@ impl RootDatabase { | |||
246 | hir::db::InherentImplsInCrateQuery | 233 | hir::db::InherentImplsInCrateQuery |
247 | hir::db::TraitImplsInCrateQuery | 234 | hir::db::TraitImplsInCrateQuery |
248 | hir::db::TraitImplsInDepsQuery | 235 | hir::db::TraitImplsInDepsQuery |
249 | hir::db::InternTypeCtorQuery | ||
250 | hir::db::InternTypeParamIdQuery | ||
251 | hir::db::InternChalkImplQuery | ||
252 | hir::db::InternAssocTyValueQuery | ||
253 | hir::db::AssociatedTyDataQuery | 236 | hir::db::AssociatedTyDataQuery |
254 | hir::db::TraitDatumQuery | 237 | hir::db::TraitDatumQuery |
255 | hir::db::StructDatumQuery | 238 | hir::db::StructDatumQuery |
@@ -264,6 +247,36 @@ impl RootDatabase { | |||
264 | // LineIndexDatabase | 247 | // LineIndexDatabase |
265 | crate::LineIndexQuery | 248 | crate::LineIndexQuery |
266 | ]; | 249 | ]; |
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 | |||
267 | acc.sort_by_key(|it| std::cmp::Reverse(it.1)); | 280 | acc.sort_by_key(|it| std::cmp::Reverse(it.1)); |
268 | acc | 281 | acc |
269 | } | 282 | } |
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 14982919d..846264046 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs | |||
@@ -273,12 +273,22 @@ pub fn analysis_stats( | |||
273 | println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); | 273 | println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); |
274 | 274 | ||
275 | if memory_usage { | 275 | if memory_usage { |
276 | for (name, bytes) in host.per_query_memory_usage() { | 276 | let mut mem = host.per_query_memory_usage(); |
277 | println!("{:>8} {}", bytes, name) | 277 | |
278 | } | 278 | let before = ra_prof::memory_usage(); |
279 | drop(vfs); | ||
280 | let vfs = before.allocated - ra_prof::memory_usage().allocated; | ||
281 | mem.push(("VFS".into(), vfs)); | ||
282 | |||
279 | let before = ra_prof::memory_usage(); | 283 | let before = ra_prof::memory_usage(); |
280 | drop(host); | 284 | drop(host); |
281 | println!("leftover: {}", before.allocated - ra_prof::memory_usage().allocated) | 285 | mem.push(("Unaccounted".into(), before.allocated - ra_prof::memory_usage().allocated)); |
286 | |||
287 | mem.push(("Remaining".into(), ra_prof::memory_usage().allocated)); | ||
288 | |||
289 | for (name, bytes) in mem { | ||
290 | println!("{:>8} {}", bytes, name) | ||
291 | } | ||
282 | } | 292 | } |
283 | 293 | ||
284 | Ok(()) | 294 | Ok(()) |