-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 very slow/stuck #55281
Comments
@DanTup , do you see this? Have there been more reports of this kind? |
/ cc @bwilkerson |
I've not seen any other reports like this. 100% CPU certainly does not look healthy if it's persisting for a long period after initial analysis. @JonasJW a few questions:
|
We were having the same issue and using the Removing it completely seems to have solved the issue for us, are you using it too, and can you try to remove it to confirm it comes from there if you are ? |
/cc @scheglov |
@DanTup Thanks for the response and sorry for the late reply. code --status output:
To be honest, I'm not quite sure what you mean by your question about symlinks or how I can find out. Yes, this issue seems to have started just recently without making any noticeable changes such as updating SDKs, installing extensions, etc. Here are further screenshots, I hope this is the server timing page you meant. If you have any recommendations what I can try to fix this issue, I'm happy to try that. As mentioned, I have already tried uninstalling Flutter/Dart, VSCode, etc. at the moment I don't know what else I could try. |
For us updating |
@JonasJW thanks - the page I meant was the one marked "Timing" on the left. Can you also confirm whether you're using any analyzer plugins? A few comments above suggest You should be able to check for symlinks by running |
@DanTup thanks for the clarification! I don't use When I run
Is that anything out of the ordinary? Here the screenshots of the "Timing" page: |
That one doesn't look like a problem, but are there any that point back up the tree (eg. creating cycles or including other large parts of the disk in the the path)? It may be useful to enable the analyzer instrumentation log (this file can get very large - be sure to turn it off afterwards) and reproduce the issue, and see if there is anything in the log file that looks out of place while this happens (for example exceptions, or paths you would not expect to be analyzed with this project open being analyzed). You mentioned this only happens on large projects - are any of them public projects that I could test with (or that sharing logs from would not include anything sensitive)? |
Hi @DanTup, I apologize for taking so long to respond. I still have this issue and it's really slowing down my development process.
Here are a few symlinks, some point up but it doesn't appear to me that they would create a cycle
In total there are over 550 symlinks. Does any of this sound problematic? I also tried the analyzer instrumentation logs but I can't really find anything that appears out of place. However, this document seems to log all kinds of stuff and I'm not sure how to analyze it or what to look for. Yes, unfortunately, this project is private and can't be shared. I could probably share the analyzer instrumentation logs privately with you, if that would help. I recently tested this project on a windows laptop and the issue occurs as well. (Thus, I think completely reinstalling my mac won't even help fix it). These issues don't appear on new Flutter projects. Maybe I could try to download a big public project and see if I have problems with other bigger projects as well? If not it must be something specific with my project but I'm clueless about where the issue could be. |
Nothing above looks like an issue to me - the issue would be if the link points further up the tree so that walking the tree could cause endless cycles.
The most useful thing would be knowing what's being logged during the periods where performance is bad. So if the bad performance is during startup, it would be the start of the logs (until the first
I can't accept anything confidential (instrumentation logs can contain contents of opened files and paths/errors for other files in the workspace), but if you're able to reproduce this on a copy of the project with anything confidential removed (and perhaps only a single test file open), you might be able to get a log that doesn't contain anything confidential you can share. Something I forgot to ask earlier - can you confirm whether you have this option ticked in the VS Code (User or Workspace) settings? |
Understood, I will go back to the logs and look for these progress events. If I have something to share I will follow up on it here. The |
FWIW, my recommendation would be to not use that setting (and I should update the text). Although it sounds better for large projects, it was really added for a fairly specific case (command line editors that would provide the current working directory - which may be the user home dir - as the workspace folder). While the server will start up faster for very large workspaces, opening and closing files from different projects will trigger re-creating the analysis roots which can trigger "initial" analysis for those projects. It's beneficial if you're opening a folder that contains 100 projects and maybe only opening files from a handful, but if you're jumping between a large portion of the projects in the workspace, it's probably worse overall. |
@JonasJW what is your current experience with analysis performance? Are you still experiencing this weird behavior? |
@mraleph yes, I'm still experiencing performance issues |
@JonasJW are you able to reproduce this issue with any public projects? It might be easier to narrow down with an instrumentation log, but that log will contain parts of source code from the open projects. If it only occurs with this one specific internal project, is it possible to make a copy of it and see if you can narrow down what causes it (for example if it's made up of many packages, can you remove some of them to narrow down if it's caused by a specific package/set of packages)? Do you also know if this issue occurs when typing in any file, or just some subset? This issue could be similar to #56307 which may be caused by the number of files that need to be reanalyzed as you modify a file (see #56307 (comment) and #56307 (comment)). |
Maybe a related issue |
@larssn not much we can do about that |
@mraleph Of course. dart_analyzer_diagnostics_report-2.json Here's a |
@larssn thanks! unfortunately the report does not contain the most useful information about analyzer memory usage, due to a regression which accidentally snuck in when we changed how LSP is started. Could you try this instead:
This will try to find all This should produce output like this: $ dart pub global activate -sgit https://github.com/mraleph/dart_lsp_collect_global_report
Downloading packages... .
+ collection 1.19.1
+ dart_lsp_collect_global_report 1.0.0 from git https://github.com/mraleph/dart_lsp_collect_global_report at 97e624
+ vm_service 14.3.1
Building package executables...
Built dart_lsp_collect_global_report:dart_lsp_collect_global_report.
Installed executable dart_lsp_collect_global_report.
Activated dart_lsp_collect_global_report 1.0.0 from Git repository "https://github.com/mraleph/dart_lsp_collect_global_report".
$ dart pub global run dart_lsp_collect_global_report
Finding Dart LSP processes
Finding all open ports
Checking for development-service processes
Sending SIGQUIT to 87732 in attempt to start vm-service
... OK
Finding all open ports
Checking for development-service processes
Trying to fetch data from LSP process 35597 via ws://127.0.0.1:56167/RPaRxD3Yj0E=/ws
... OK
Trying to fetch data from LSP process 35651 via ws://127.0.0.1:56168/4ONWEeRWOrA=/ws
... OK
SUCCESS: written lsp-report.json |
Is this fixed now, or does something need updating in the LSP server?
TIL! :) |
I will take a look at it next. I have a work-around but I want to understand what happened. When we launch analysis server through dartdev (e.g. |
I checked out the source, and I see what it's trying to do. Here's my output:
The |
@larssn hmm, strange. Lets try again: I have added more logging so we can at least see what is going wrong: $ dart pub global activate -sgit https://github.com/mraleph/dart_lsp_collect_global_report
Package dart_lsp_collect_global_report is currently active from Git repository "https://github.com/mraleph/dart_lsp_collect_global_report".
Downloading packages... .
~ dart_lsp_collect_global_report 1.0.0 from git https://github.com/mraleph/dart_lsp_collect_global_report at e2f0f2 (was 1.0.0 from git https://github.com/mraleph/dart_lsp_collect_global_report at 96a2f2)
Building package executables...
Built dart_lsp_collect_global_report:dart_lsp_collect_global_report.
Installed executable dart_lsp_collect_global_report.
Activated dart_lsp_collect_global_report 1.0.0 from Git repository "https://github.com/mraleph/dart_lsp_collect_global_report".
$ dart pub global run dart_lsp_collect_global_report
Finding Dart LSP processes
| 35597 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/bin/dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.98.1
| 35651 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/bin/dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.98.1
| 77607 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/bin/dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.98.1
Trying to fetch vm-service URIs
Finding all open ports
-> Ports open by LSP processes:
| 35597 [56167]
| 35651 [56168]
| 77607 [57784]
Checking for development-service processes
| 71809 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/bin/dart development-service --vm-service-uri=http://127.0.0.1:56167/RPaRxD3Yj0E=/ --bind-address=localhost --bind-port=0 --serve-devtools
| 71810 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/bin/dart development-service --vm-service-uri=http://127.0.0.1:56168/4ONWEeRWOrA=/ --bind-address=localhost --bind-port=0 --serve-devtools
| 77657 /Users/vegorov/src/flutter/flutter/bin/cache/dart-sdk/bin/dart development-service --vm-service-uri=http://127.0.0.1:57784/xAxOESCVTeg=/ --bind-address=localhost --bind-port=0 --serve-devtools
| 35597 ws://127.0.0.1:56167/RPaRxD3Yj0E=/ws
| 35651 ws://127.0.0.1:56168/4ONWEeRWOrA=/ws
| 77607 ws://127.0.0.1:57784/xAxOESCVTeg=/ws
Trying to fetch data from LSP process 35597 via ws://127.0.0.1:56167/RPaRxD3Yj0E=/ws
... OK
Trying to fetch data from LSP process 35651 via ws://127.0.0.1:56168/4ONWEeRWOrA=/ws
... OK
Trying to fetch data from LSP process 77607 via ws://127.0.0.1:57784/xAxOESCVTeg=/ws
... OK
SUCCESS: written lsp-report.json |
Cool, that did the trick.
Here's the output: |
Thanks! Top memory consumers seem to be:
That's 600Mb in strings and 430Mb in @larssn what is the size of your code base? e.g. if you do |
My report if it helps
|
Here's the cloc output:
Yes, we use |
I use freezed library but it is excluded from the analyzer
|
I suspect that |
#55281 will remove |
@larssn @amrgetment would it be possible for you to try a bleeding edge SDK build to see if there a significant improvement in memory usage? Bleeding edge build for Apple Silicon Macs is located here. Dev build with @scheglov's change is not ready yet (c17dd35 is in 3.7.0-95.0.dev or newer). You should be able to download and unpack SDK somewhere and then simply point VS Code to it via ( |
Done. Seems to have helped greatly with performance. Good job! |
@larssn could you try an |
Of course! edit @mraleph And if you need me onsite, it's but a short bike ride 😁 |
@larssn nice diff comparing to the previous report, which I think confirms improvements from @scheglov's patch. Nice improvement!
Total change in memory consumption: -788815120 Diffs are not directly comparable because, I think, depending on the timing when snapshot is taken there might be different things hanging in memory, but if this holds this is huge improvement to memory usage. PS.
I would not be able to look at your code for reasons, but I made a mental note of that :) |
how could I use it for Intel Mac or when will this fix be released? |
You can download bleeding edge SDK to try it from here:
If you are asking when it will be included into a stable release - then the answer is: 3-6 months from now, because we are just past one stable release. |
Bug: #55281 Change-Id: Ie8d2a7f3d5ea9408320312d49eb67561ca463289 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393480 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
Dart & Flutter has suddenly become unusable slow in VSCode. Intellisense won't load within 30+ seconds, syntax highlighting won't update, jumping to code definitions loads infinitely, etc.
This seems to be especially the case on bigger projects, on a newly created project it works fine. I tried switching to Android Studio which seems to behave similarly (maybe a little better).
I tried uninstalling all extensions, even completely removing VSCode with any data stored and reinstalling it. As soon as I install the Dart extension, it is unusable. I also tried setting the following settings:
I'm on macOS 14.4, VSCode Version 1.87.2 (Universal),
In the Activity Monitor, there is the
dart:analysis_server.dart.snapshot
process running with around 1 GB of used memory. I'm not sure if this is normal.Here is a screenshot from the Dart Analyzer (which I'm also having trouble opening)
dart info
output:General info
Project info
Process info
Any recommendations on how I could possible fix this would be very welcome!
The text was updated successfully, but these errors were encountered: