Open alanhkarp opened 3 years ago
Just to make sure, are you saying you keep it running for a couple of weeks?
Or longer. I think the last time I shut VSCode down before this was for a MacOS update.
Alan Karp
On Mon, Jan 25, 2021 at 7:06 PM Laurențiu Nicola notifications@github.com wrote:
Just to make sure, are you saying you keep it running for a couple of weeks?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-analyzer/rust-analyzer/issues/7439#issuecomment-767258235, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFAT43LDUYDB56IU232LZDS3YWTHANCNFSM4WSS5MXQ .
Can you try running the "Rust Analyzer: Memory Usage" command the next time?
I'll try to remember.
Alan Karp
On Tue, Jan 26, 2021 at 2:03 AM Florian Diebold notifications@github.com wrote:
Can you try running the "Rust Analyzer: Memory Usage" command the next time?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-analyzer/rust-analyzer/issues/7439#issuecomment-767436552, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFAT4ZW7Y2CCIR7ELXXTK3S32HP5ANCNFSM4WSS5MXQ .
Just a data point. According to the Mac Activity Monitor, the analyzer increases its memory use by about 100 MB/day when I'm running my application a lot. The analyzer running with VSCode in another window that runs the web server I use for my visualization hasn't increased its memory use much if at all.
I'm sympathetic. The first Java product I was involved in initially had a 1 KB/hour memory leak, which was a huge amount back in 1998.
Alan Karp
On Tue, Jan 26, 2021 at 2:03 AM Florian Diebold notifications@github.com wrote:
Can you try running the "Rust Analyzer: Memory Usage" command the next time?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-analyzer/rust-analyzer/issues/7439#issuecomment-767436552, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFAT4ZW7Y2CCIR7ELXXTK3S32HP5ANCNFSM4WSS5MXQ .
I noticed this as well. Over the course of an evening, ra went from ~100MB baseline to nearly 700MB and the build directory kept locking when I tried to build resulting in slow completions.
@flodiebold running the command reset the ra executable to baseline, but I don't think this is what you expected: https://gist.github.com/Halkcyon/6fbf7bd87a74597b82aba5150bb276fc
Rust analyzer is getting slow, so I ran the memory analyzer. I can send you the output, but it doesn't look useful It's a bunch of lines like
0b TyQuery
0b TyQuery (deps)
0b TyQuery (purge)
0b ValueTyQuery
0b ValueTyQuery (deps)
0b ValueTyQuery (purge)
Every line starts with 0b.
Interesting. While I was typing this email, the memory use went from 1.4 GB to 530 MB in the Mac Activity Monitor.
Alan Karp
On Tue, Jan 26, 2021 at 2:03 AM Florian Diebold @.***> wrote:
Can you try running the "Rust Analyzer: Memory Usage" command the next time?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-analyzer/rust-analyzer/issues/7439#issuecomment-767436552, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFAT4ZW7Y2CCIR7ELXXTK3S32HP5ANCNFSM4WSS5MXQ .
Memory usage is only reported on Linux with glibc: https://github.com/rust-analyzer/rust-analyzer/blob/d8dfcc2c0cf87162ec5791121f484dd7fde8d17d/crates/profile/src/memory_usage.rs#L27
I have another data point on slow editing responsiveness. VSCode got very slow for editing after a week or so since the last restart, so I checked and saw it was using about 1.5 GB of memory. I closed and reopened VSCode, and it started running with about 900 MB. Editing responsiveness was good, but I saw that the memory footprint quickly jumped to 2.4 GB and is now over 3.1 GB. Editing performance is still good. My experience is all with the same project.
Alan Karp
On Tue, Jan 26, 2021 at 2:03 AM Florian Diebold @.***> wrote:
Can you try running the "Rust Analyzer: Memory Usage" command the next time?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-analyzer/rust-analyzer/issues/7439#issuecomment-767436552, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFAT4ZW7Y2CCIR7ELXXTK3S32HP5ANCNFSM4WSS5MXQ .
Yet another data point. The Rust analyzer is now taking almost 21 GB, but VSCode is quite responsive.
This "bigger"(new) leak is due to a mistake that was found in https://github.com/rust-analyzer/rust-analyzer/issues/8181 which got introduced this week
Hi. I have a running rust-analyser
process taking 24 GB of resident memory. Is there something I can do to help find out where that space is being spent inside the process? This is in Code OSS (Archlinux’s build of VSCode).
Can you try running the "Rust Analyzer: Memory Usage" command the next time?
I only have a "Rust Analyzer: Memory Usage (Clears Database)" command, which sounds like it would destroy the evidence I’d like to investigate.
That is the right command. It calculates the memory usage by comparing the memory usage before and after clearing certain parts of the internal database used for caching.
Ok, I can try it, but is there another command that can trace memory usage without clearing, in case keeping pathologically caches around is useful for further investigation? It takes a long time of actively using the IDE to get to this point, and I’m not sure how to reproduce.
Not that I know of.
After a couple minutes with one CPU thread busy, I got the report below but resident size of the process is basically unchanged
I can confirm the issue:
After few seconds memory usage is ~1.8Gb in little project with tokio dependency
@isqad how much memory does rust-analyzer analysis-stats .
use if you run it from your project directory?
Is your code public?
Tokio is a big dependency; it doesn't matter how small the project is. While 1.8G is more than we'd like it to use, it doesn't indicate that there's a memory leak.
While 1.8G is more than we'd like it to use, it doesn't indicate that there's a memory leak.
Yes, it is. Sorry for mistake, memory is not increase more than 1.8Gb
I have a (near empty) project in combination with Visual Studio Code + Flatpak Extension, where rust-analyzer leaks/takes all available memory (16GB). rust-analyzer has normal memory usage, when run without Flatpak Extension.
At ~4GB I ran Rust Analyzer: Memory Usage
- maybe it helps.
Per-query memory usage:
96mb 11427 HygieneFrameQuery
92mb 30013 FileItemTreeQuery
60mb 70 CrateDefMapQueryQuery
51mb 27903 MacroArgNodeQuery
46mb 165514 AttrsQuery
45mb 3629 FileTextQuery
35mb 68659 ImplDataWithDiagnosticsQuery
25mb 2139 ParseQuery
24mb 30030 AstIdMapQuery
18mb 119917 InternFunctionQuery
17mb 27907 MacroExpandQuery
15mb 27907 ParseMacroExpansionQuery
15mb 68658 ImplTraitQuery
15mb 68658 ImplSelfTyQuery
14mb 68659 ImplDataQuery
9mb 68659 InternImplQuery
9mb 414 DeclMacroExpanderQuery
9mb 29928 InternMacroCallQuery
2930kb 19004 InternTypeAliasQuery
2404kb 14558 InternConstQuery
1895kb 3992 FunctionDataQuery
1044kb 35 ExpandProcMacroQuery
957kb 1109 TraitDataWithDiagnosticsQuery
629kb 1 CrateGraphQuery
586kb 325 EnumDataWithDiagnosticsQuery
548kb 219 BlockDefMapQuery
535kb 5071 InternStructQuery
377kb 1 ProgramClausesForChalkEnvQuery
338kb 236 BodyWithSourceMapQuery
270kb 686 InternMacroRulesQuery
227kb 0 UnionDataWithDiagnosticsQuery
202kb 1109 TraitDataQuery
157kb 236 BodyQuery
141kb 67 ImplDatumQuery
117kb 612 InternEnumQuery
113kb 3 ConstDataQuery
113kb 386 TypeAliasDataQuery
108kb 1460 InternTraitQuery
101kb 219 InternBlockQuery
96kb 1 FnDefVarianceQuery
85kb 90 InternExternBlockQuery
75kb 2 AssociatedTyValueQuery
68kb 57 TraitSolveQueryQuery
63kb 19 InternUnionQuery
47kb 264 InternStaticQuery
44kb 1 FnDefDatumQuery
43kb 3 ExprScopesQuery
41kb 0 Macro2DataQuery
37kb 325 EnumDataQuery
32kb 1 LibraryRootsQuery
24kb 1 ProcMacrosQuery
10kb 0 ModuleSymbolsQuery
2512b 0 MacroRulesDataQuery
-2944b 40 InternMacro2Query
-4kb 1 LocalRootsQuery
-9kb 0 StaticDataQuery
-18kb 0 TraitAliasDataQuery
-37kb 0 LibrarySymbolsQuery
-54kb 6 StructDatumQuery
-59kb 1 AssociatedTyDataQuery
-63kb 1 LineIndexQuery
-102kb 5 AdtVarianceQuery
-107kb 0 ProcMacroDataQuery
-159kb 1 InternTraitAliasQuery
-173kb 8 StructDataWithDiagnosticsQuery
-186kb 0 UnionDataQuery
-265kb 27 InternProcMacroQuery
-399kb 24 TraitDatumQuery
-805kb 0 InternGeneratorQuery
-2314kb 11 CrateLangItemsQuery
-2551kb 6775 GenericDefaultsQuery
-2554kb 5435 TyQuery
-3101kb 3 FieldTypesQuery
-3196kb 0 LayoutOfAdtQuery
-3252kb 0 InherentImplsInBlockQuery
-3300kb 22 CallableItemSignatureQuery
-3431kb 12 FunctionVisibilityQuery
-3641kb 0 BorrowckQuery
-3668kb 70 GenericPredicatesForParamQuery
-3871kb 2 ReturnTypeImplTraitsQuery
-3911kb 0 ConstEvalQuery
-4038kb 113 GenericPredicatesQuery
-4mb 1 TraitImplsInDepsQuery
-4mb 4 TargetDataLayoutQuery
-4mb 0 MirBodyQuery
-4mb 0 ConstEvalDiscriminantQuery
-4mb 0 ImportMapQuery
-4mb 11 InternCallableDefQuery
-4mb 21 LangItemQuery
-4mb 6 TraitEnvironmentQuery
-5mb 70 TraitImplsInCrateQuery
-5mb 584 ConstParamTyQuery
-5mb 3 InferQueryQuery
-5mb 1 ConstVisibilityQuery
-5mb 12 ValueTyQuery
-5mb 0 InternClosureQuery
-6mb 0 InternImplTraitIdQuery
-6mb 0 TraitImplsInBlockQuery
-6mb 2 SourceRootCratesQuery
-6mb 0 IncoherentInherentImplCratesQuery
-6mb 0 FieldsAttrsSourceMapQuery
-6mb 3 InternTypeOrConstParamIdQuery
-7mb 3629 FileSourceRootQuery
-8mb 0 InternLifetimeParamIdQuery
-8mb 75483 GenericParamsQuery
-9mb 0 VariantsAttrsSourceMapQuery
-9mb 1 InherentImplsInCrateQuery
-11mb 0 CrateSupportsNoStdQuery
-12mb 74 SourceRootQuery
-13mb 0 FieldsAttrsQuery
-19mb 0 FieldVisibilitiesQuery
-23mb 8 StructDataQuery
-39mb 301 VariantsAttrsQuery
3957mb Remaining
(note: database has been cleared)
The Rust analyzer uses a bit less than 1 GB of memory for each of my 2 projects when I start VSCode. After several weeks, it starts to get slow, no longer keeping up with my typing. When I look, I see it is consuming almost 2 GB. My project defines no macros, but I use lots of crates that do.