Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart Analyzer, high CPU, massive log file #43765

Closed
SteveAlexander opened this issue Oct 12, 2020 · 10 comments
Closed

Dart Analyzer, high CPU, massive log file #43765

SteveAlexander opened this issue Oct 12, 2020 · 10 comments
Labels
analyzer-stability area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@SteveAlexander
Copy link

I'm regularly (several times a day) going through a cycle of VS Code becoming unusable due to the Analyzer using all the CPU. I have the log file enabled, and it quickly writes multi-gigabyte log files.

I don't have a clean reproduction of this at this moment — I'll look at that later.

When it starts going wrong, the log file looks like this: (I manually split the lines to make this appear readable in github)

1602504045559:Noti:{"event"::"completion.availableSuggestions","params"::{"changedLibraries"::
[{"id"::0,"uri"::"package::projectname/sync/database.dart","items"::
[{"label"::"$ItemsTable","declaringLibraryUri"::"package::projectname/sync/database.dart","element"::
{"kind"::"CLASS","name"::"$ItemsTable","location"::{"file"::"/Users/steve/code/companyname/projectname-
app/projectname/lib/sync/database.g.dart","offset"::20093,"length"::0,"startLine"::614,"startColumn"::7},"flags"::0},"relevanceTags"::
["ElementKind.CLASS","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart:
:::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Item
sTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable",
"package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","packa
ge::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::proj
ectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectnam
e/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/
database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/databas
e.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart:::
:$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Items
Table","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","
package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","packag
e::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::proje
ctname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname
/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/d
atabase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database
.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::
$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsT
able","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","p
ackage::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package:
:projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::project
name/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/s
ync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/dat
abase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.d
art::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$It
emsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTab
le","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pac
kage::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::p
rojectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectn
ame/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sy
nc/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/data
base.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.da
rt::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Ite
msTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTabl
e","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pack
age::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::pr
ojectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectna
me/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/syn
c/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/datab
ase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dar
t::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Ite
msTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTabl
e","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pack
age::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::pr
ojectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectna
me/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/syn
c/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/datab
ase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dar
t::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Ite
msTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTabl
e","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pack
age::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::pr
ojectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectna
me/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/syn
c/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/datab
ase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dar
t::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Ite
msTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTabl
e","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pack
age::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::pr
ojectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectna
me/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/syn
c/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/datab
ase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dar
t::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Ite
msTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTabl
e","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pack
age::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::pr
ojectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectna
me/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/syn
c/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/datab
ase.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dar
t::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$Ite
msTable","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTabl
e","package::projectname/sync/database.dart::::$ItemsTable","package::projectname/sync/database.dart::::$ItemsTable","pack
age::projectname/sync/database.dart::::$ItemsTable:

The line goes on a lot longer than this.

I am using https://pub.dev/packages/moor, which uses generated code at database.g.dart and creates things like $ItemsTable as part of its functioning.

  • VS Code version: 1.49.3
  • Dart extension version: 3.15.0
  • Dart/Flutter SDK version: Dart SDK version: 2.10.0 (stable) (Mon Sep 28 09:21:23 2020 +0200) on "macos_x64"
@SteveAlexander
Copy link
Author

The log says "location"::{"file"::"/Users/steve/code/companyname/projectname- app/projectname/lib/sync/database.g.dart","offset"::20093,"length"::0,"startLine"::614,"startColumn"::7}. That's this generated code:

class $ItemsTable extends Items with TableInfo<$ItemsTable, Item> {
  final GeneratedDatabase _db;
  final String _alias;
  $ItemsTable(this._db, [this._alias]);
  final VerificationMeta _baseMeta = const VerificationMeta('base');
  GeneratedIntColumn _base;
  @override
  GeneratedIntColumn get base => _base ??= _constructBase();

@srawlins srawlins added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Oct 13, 2020
@SteveAlexander
Copy link
Author

This issue is making it painful to develop a flutter app. I get about 5 minutes of use from the analyzer before I need to restart it.

Is there anything I can do to work around the problem? Or anything I can do to help towards a fix?

@Auuufff
Copy link

Auuufff commented Nov 2, 2020

I have the same issue in Android Studio and VSC.

@seanmc86
Copy link

seanmc86 commented Nov 3, 2020

Same issue in VSCode and IDEA. Any IDEs open with the Dart plugin active, regardless of whether there are active debugging sessions or not, steadily take up more and more CPU usage until they become unusable after a few minutes.

Dart SDK version: 2.10.3 (stable) (Tue Oct 27 14:44:30 2020 +0100) on "macos_x64

@DanTup
Copy link
Collaborator

DanTup commented Nov 3, 2020

Can anyone reproduce this in a small sample project that can be shared?

@SteveAlexander
Copy link
Author

I've been trying to do this — unfortunately, my project is not currently suffering from this, and I don't have a straightforward way to go back to a state that does reproduce.

When I next experience the problem, I'll take a copy of the project tree, and try to pare it down to a reproducible test case.

Unfortunately I cannot say when I'm able to do this, as I need to see when I start experiencing this problem again.

@seanmc86
Copy link

I've been unable to reproduce the issue in all except one of my repos. It's a Flutter desktop project, but using go-flutter & hover rather than the official desktop-embedding (I'm not sure if that info helps).

I saw another thread in which the following information was requested, so I'm dumping it in. Anything else I can look for log-wise?

code --status
Version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-11T01:11:34.018Z)
OS Version: Darwin x64 19.6.0
CPUs: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2200)
Memory (System): 16.00GB (1.99GB free)
Load (avg): 5, 6, 5
VM: 0%
Screen Reader: no
Process Argv: --crash-reporter-id 79b16596-d9b7-4bf8-9ba2-da74fa5e7016
GPU Status: 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled

CPU % Mem MB PID Process
2 115 41470 code main
3 66 41473 gpu-process
0 33 41475 utility
0 98 41538 shared-process
0 0 42160 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
9 262 41561 window (hovering_attach_options.dart — desktop-app)
0 0 41562 /bin/zsh -l
0 16 41646 hover run
6 1016 41899 ./go/build/outputs/darwin/worldr
0 0 41911 bash /Users/sean/SDK/flutter/bin/flutter attach --target lib/main_desktop.dart --device-id flutter-tester --debug-uri http://127.0.0.1:50300/
1 213 41928 /Users/sean/SDK/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev --packages=/Users/sean/SDK/flutter/packages/flutter_tools/.packages /Users/sean/SDK/flutter/bin/cache/flutter_tools.snapshot attach --target lib/main_desktop.dart --device-id flutter-tester --debug-uri http://127.0.0.1:50300/
0 623 41958 electron_node config.js
0 98 41566 extensionHost
80 180 41574 /Users/sean/SDK/flutter/bin/cache/dart-sdk/bin/dart /Users/sean/SDK/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot --client-id=VS-Code --client-version=3.16.0
0 0 41575 bash /Users/sean/SDK/flutter/bin/flutter daemon
0 147 41594 /Users/sean/SDK/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev --packages=/Users/sean/SDK/flutter/packages/flutter_tools/.packages /Users/sean/SDK/flutter/bin/cache/flutter_tools.snapshot daemon
0 0 41631 /usr/bin/script -t 0 /dev/null xcrun xcdevice observe --both
0 33 41632 /Applications/Xcode.app/Contents/Developer/usr/bin/xcdevice observe --both
0 557 41567 watcherService
0 33 41568 searchService
0 0 42083 /bin/zsh -l
0 0 42143 bash /usr/local/bin/code --status
17 33 42153 electron_node cli.js

Workspace Stats:
| Window (hovering_attach_options.dart — desktop-app)
| Folder (desktop-app): 4862 files
| File types: pcm(755) timestamp(610) svg(400) d(242) dia(237) o(237)
| dart(157) hmap(150) h(141) otf(64)
| Conf files: launch.json(1)
| Launch Configs: dart(2)

@DanTup
Copy link
Collaborator

DanTup commented Nov 17, 2020

@seanmc86 I think the most useful thing would be a project that repros it. Are you able to duplicate your project that has this and strip out anything you can't share to see if it still occurs in a form you could share?

@seanmc86
Copy link

Because it was so project-specific in my case, I was quite certain it must be something to do with either the files in that project's folder or the type of project files I was working with.
Turns out that that deleting the project folder and recloning it resolved the issue in the short term, though I do see instances of the usage starting to slowly creep up again over time. I'm not sure if it's a git thing or some other hidden files being created by the hot reloads/restarts I'm unaware of, but either way it doesn't seem to be a dart sdk issue.

@jcollins-g jcollins-g added the P2 A bug or feature request we're likely to work on label Oct 14, 2021
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Mar 13, 2024
@mraleph
Copy link
Member

mraleph commented Oct 3, 2024

This seems stale and unactionalble.

@mraleph mraleph closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-stability area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants