-
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 |
Before Reset Timers: After Reset Timers: Report file: dart_analyzer_diagnostics_report.json Video of what I was doing: Untitled.video.mp4 |
I see quite a lot libraries loaded in the examples above: Also, the number of |
Actually, since this bug is a bit difficult to reproduce on demand, I did the following:
|
I managed to reproduce this bug again. This time, the log corresponds to the duration of the video: Before Reset Timers: After Reset Timers: Report file: dart_analyzer_diagnostics_report.json Video of what I was doing: simplescreenrecorder-2025-03-04_19.29.22.mp4 |
I also encountered this situation, which greatly affected the development efficiency and experience |
Thank you @luis901101. In both cases at least part of the problem seems to be that the IDE issues a whole lot of (similar) requests - E.g. I found one instance where over the span of less than 7.2 seconds, 27 Thoughts currently running through my mind:
|
The IDE asks for fixes every time the cursor location changes so that the lightbulb menu has the fixes for the current location.
Yes. I believe that we could and should de- dup the requests.
Good question. If we can reproduce this behavior we can add a way to get timing information from the operation so that we can answer that question. |
Confirming that this is w/ IntelliJ/Android (not vscode)? |
For me it happens with VSCode |
For the two examples that we got data for here, yes - in both cases the client is |
@maxhuk If you could follow the steps in #55281 (comment) and provide us data that would be helpful. Thanks! |
I'm also suffering the latency in code completion and analyzing. It often stuck at highlighting and preparing code completion (where before I can navigation to variable/class definition). And it does not update analyze info after Post log here because on my machine it seems the most time consume stage is Logsbefore reset timer, the server has been running for a while:
after reset timer and stuck again:
json file: dart_analyzer_diagnostics_report.json What am i doing Writing code and jump between files by navigating to definition, sometimes it lose highlighting and I have to wait for it. Infodart info$ dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
#### General info
- Dart 3.7.0 (stable) (Wed Feb 5 04:53:58 2025 -0800) on "windows_x64"
- on windows / "Windows 11 专业版" 10.0 (Build 22631)
- locale is zh-CN
#### Project info
- sdk constraint: '>=3.7.0 <4.0.0'
- dependencies: args, bbob_dart, bloc, chat_bottom_container, collection, cookie_jar, dart_mappable, dio, dio_brotli_transformer, dio_cookie_manager, drift, drift_dev, drift_flutter, easy_refresh, equatable, extended_nested_scroll_view, file_picker, flex_color_scheme, flutter, flutter_bloc, flutter_local_notifications, flutter_localizations, flutter_markdown, flutter_svg, font_awesome_flutter, fpdart, get_it, gitsumu, go_router, html, image_picker, json_annotation, material_design_icons_flutter, path, path_provider, permission_handler, responsive_framework, rxdart, shimmer, slang, slang_flutter, sqlite3, sqlite3_flutter_libs, stream_transform, super_sliver_list, surf_lint_rules, system_theme, talker, talker_flutter, universal_html, url_launcher, uuid, web, widget_zoom, window_manager
- dev_dependencies: build_runner, custom_lint, dart_mappable_builder, flutter_launcher_icons, flutter_test, json_serializable, pyramid_lint, slang_build_runner, very_good_analysis
- elided dependencies: 2
#### Process info
| Memory | CPU | Elapsed time | Command line |
| ------: | --: | -----------: | ------------ |
| 2077 MB | -- | | dart.exe |
| 45 MB | -- | | dart.exe |
| 16 MB | -- | | dart.exe |
| 18 MB | -- | | dart.exe |
| 117 MB | -- | | dart.exe |
| 143 MB | -- | | dart.exe |
| 25 MB | -- | | dart.exe |
| 1494 MB | -- | | dart.exe |
| 107 MB | -- | | dart.exe | Codebase size:# Ignore codegen files.
✿ tokei lib
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
Dart 427 42970 30106 7987 4877
JSON 10 2669 2669 0 0
===============================================================================
Total 437 45639 32775 7987 4877
===============================================================================
# Include codegen files.
✿ tokei lib --no-ignore
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
Dart 500 100752 78453 9295 13004
JSON 10 2669 2669 0 0
===============================================================================
Total 510 103421 81122 9295 13004
=============================================================================== IDEIntelliJ IDEA 2024.3.4 (Ultimate Edition)
Build #IU-243.25659.39, built on February 27, 2025
Runtime version: 21.0.6+8-b631.39 amd64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 16
Registry:
debugger.new.tool.window.layout=true
ide.experimental.ui=true
terminal.new.ui=true
org.toml.json.schema=false
Non-Bundled Plugins:
com.jetbrains.gerryPurpleTheme (2025.1.0222)
com.thvardhan.gradianto (5.5)
monokai-pro (2.0.1)
com.github.catppuccin.jetbrains (3.4.1)
com.vecheslav.darculaDarkerTheme (1.2.0)
com.arcticicestudio.nord.jetbrains (0.13.0)
color.scheme.Tokyo Night (0.3)
com.zeekbtye.tokyonight (0.2.0)
club.nutsoft.Github3Theme (1.2.2)
io.ddiu.moegi.theme.jetbrains (0.0.3)
IdeaVIM (2.19.0)
labs.hardhacker.theme.jetbrains (0.2.6)
com.jetbrains.rust (243.24978.86)
io.github.frykher.jetbrains-kanagawa-theme (1.2.2)
com.jetbrains.darkPurpleTheme (1.3)
com.github.ewwwdp.darker-horizon (1.0.1)
neon-cat (1.0.3)
com.herbert.george.dart.extensions (0.0.1+3)
com.xinkun.theme.md (1.7.12)
net.antelle.intellij-xcode-dark-theme (1.2.4)
com.github.lonre.gruvbox-intellij-theme (0.6.3)
GrepConsole (13.2.0-IJ2023.3)
Dart (243.23654.44)
com.localizely.flutter-intl (1.18.8-2024.2)
com.nasller.CodeGlancePro (1.9.6)
org.jetbrains.android (243.25659.39)
io.flutter (83.0.4)
androidx.compose.plugins.idea (243.23654.117)
com.android.tools.design (243.23654.189)
ru.adelf.idea.dotenv (2024.3)
izhangzhihao.rainbow.brackets (2024.2.9-241)
zielu.gittoolbox (600.0.14+243)
com.brandiico.jetbrains-nightfall-theme (2.0.3)
Kotlin: 243.25659.39-IJ |
Steps to reproduce: open flutter framework in VSCode on Windows (seems to be less severe on macOS). Open Wait for the dust to settle. Go inside abstract mixin class WidgetsBindingObserver {
void x() {
// trigger autocomplete here before saving the changes
} Analysis timing reset right before adding the method and triggering autocomplete:
After some editing things get so bad the analyzer basically stops responding and needs to be restarted. This is with current main:
|
@realth000 thanks for the file - there are a lot of slow @knopp thanks, I can reproduce fairly long analysis when making a single-keystroke change to that file too (not to the point of needing to restart the server, but my testing was fairly limited). I've opened a specific sub-issue for this with my timings and a CPU profile at #60293. |
Also add benchmark where lots of hover requests are fired, mimicking IntelliJ behavior when holding ctrl and moving the mouse over imports. I'm getting these results on my machine: ``` 4 files / CodeType.ImportCycle: Initial analysis: 1.249438 Completion after change: 10.143719 4 files / CodeType.ImportChain: Initial analysis: 1.367604 Completion after change: 9.936909 4 files / CodeType.ImportExportCycle: Initial analysis: 1.233644 Completion after change: 10.011695 4 files / CodeType.ImportExportChain: Initial analysis: 1.226382 Completion after change: 9.875991 4 files / CodeType.ImportCycleExportChain: Initial analysis: 1.262932 Completion after change: 9.995607 ``` notice the low number of files (in the chain*) or if it even is a chain etc doesn't appear to change anything for the time it takes to become responsive again. Notice that in #55281 (comment) I noticed that something similar happened for `edit.getFixes`, but I'm yet to actually reproduce that. Change-Id: Iff04124825c6ea2f759b4d048a0f2988709eaebf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413981 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com>
TL;DR: By only responding (for real) to the newest hover request a benchmark that used to take ~10 seconds now takes ~0.6 seconds. Details: In #55281 (comment) I noticed that some of the performance issues people are seeing fom the analyzer server stem from many requests being fired, each taking longer the wait before the next is issued, naturally building up a longer and loger queue before responses are made. Their it was for `edit.getFixes`, but I'm yet to actually reproduce that. I did reproduce for hover requests though, so here I'm debounsing those hover requests. I'm hooking into the system that already debounces completion requests and following the pattern used there. On my machine, running ``` out/ReleaseX64/dart-sdk/bin/dart \ pkg/analysis_server/tool/benchmark_tools/big_chain_benchmark/legacy_many_hover_requests.dart ``` I get these numbers: Before CL (taken from the parent CL that introduces the benchmark): ``` 4 files / CodeType.ImportCycle: Initial analysis: 1.249438 Completion after change: 10.143719 4 files / CodeType.ImportChain: Initial analysis: 1.367604 Completion after change: 9.936909 4 files / CodeType.ImportExportCycle: Initial analysis: 1.233644 Completion after change: 10.011695 4 files / CodeType.ImportExportChain: Initial analysis: 1.226382 Completion after change: 9.875991 4 files / CodeType.ImportCycleExportChain: Initial analysis: 1.262932 Completion after change: 9.995607 ``` With CL: ``` 4 files / CodeType.ImportCycle: Initial analysis: 1.322501 Completion after change: 0.569768 4 files / CodeType.ImportChain: Initial analysis: 1.347588 Completion after change: 0.635748 4 files / CodeType.ImportExportCycle: Initial analysis: 1.492362 Completion after change: 0.575233 4 files / CodeType.ImportExportChain: Initial analysis: 1.331619 Completion after change: 0.576199 4 files / CodeType.ImportCycleExportChain: Initial analysis: 1.342130 Completion after change: 0.608064 ``` Change-Id: Ide3dbc4dfb885af9e1c46a763338ba545c0ab7db Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413982 Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
@realth000 thank you for the data! |
@jensjoha I restarted the dart analyzer server after I have some git submodules in my repo, those are also dart projects. You can clone my project here https://github.com/realth000/tsdm_client if you'd like to. Some new info I found yesterday: the performance got much better when I disabled most configs in Before, for the first and second config I chose "all files types" and |
FWIW I have this issue too. I'm running Dart/Flutter/Serverpod in VS Code in Windows 11 |
@parnesen please check the instructions in #55281 (comment) to collect a diagnostic report after you've reproduced the issue you're seeing. If you can reproduce on something open source / public, then please provide details and repro steps. |
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: