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
VSCode + Flutter + Dart => Rename Symbol is really slow and sometimes not even working #2231
Comments
This has been happening for me for some time. Once in a while the refactor goes off into lala land. You can actually do another refactor while it is thinking and it should do the second refactor only. That's if you know it's hung up and not because it's a complex refactor in a huge project. |
I'm struggling to repro this. The first refactor is a little slower (but only maybe 1-2 seconds) and from the logs looks like it was because the analyzer will still busy doing startup stuff (pre-loading code completions). Is anyone able to capture a log of it being really slow?
Note: The log my contain contents from your files, so please do this on a trivial project. |
Sorry for the (very) late response here. I find it to work better now but not great. I can repro this easily but the delay is more like 10 seconds now and it seems to work in most cases now. I haven't been able to repro that it fails completely. So I reproed like this: |
Thanks for the log! The relevant parts are here:
It shows around 7 seconds for the rename, but there are lots of If you leave it longer (maybe a couple of minutes?) before doing the first rename, do you still see it? (I'm not sure if it's just startup work, or if the rename is somehow triggering that work on the server). |
I've been examining this for the last couple of weeks and it seems like it's some kind of "startup" work (just as you've stated above). After the first rename, the following renames are more or less instant. However, this startup does not trigger for me until the first rename. I can open my project, work for 30 minutes, build, debug, open/close files, create classes, hot reloads etc - then I rename a symbol and it takes a long time (7 seconds in the above case). So this "startup" work isn't triggered until the first rename. Our project is currently 95 dart files (300k in total size). An interesting observation is that even if I've been running the project for say 30 or 60 minutes and then I rename a class or a field - it will take at least the above 7 seconds. But sometimes it takes more (e.g. 20 secs) and sometimes (quite often) it does not complete at all. I guess it's a timeout after 30 seconds or so? If a rename times out the loading spinner in VS Code stops moving and no error message or other info is displayed (and the symbol isn't renamed). If I try to rename the same thing (or something else) after this, it renames immediately. Another observation is that "References: Find all references" (Shift + Alt + F12) has the same issue. Finding references for a symbol can take really long time and it often times out. I guess this triggers the same kind of "indexing" job that rename uses. A workaround that is working for me is to trigger "Find all references" with my morning cup of coffee and keep VS Code open during the day. I'd like to repro this with a open source project so I can provide easy steps to reproduce and no problems sharing the logs (considering that the logs may contain info about our project). I don't have time to do that right now but hopefully in a couple of weeks or so. Sorry for late responses in for this issue! |
@mikeesouth thanks for the extra details!
I thought I saw that too - but since I wasn't waiting very long, I thought I might have just been too fast while it was still working. Since this seems to confirm it is happening, I'll capture a log with a longer wait and move this over to the SDK repo. |
I tried to repro this again recently, and I came across a performance issue - but it was only triggered in very specific circumstances (where you open VS Code with files already open, and then don't open/close any additional files). I've fixed that in the SDK, but I'm not sure it's the cause of this. For those that can reliably reproduce this, some things that may help:
|
Same issue :( Very frustrating to wait 15 seconds for renaming a variable. |
Please see the request in the comment above. If someone can share a project this happens with, along with an instrumentation log (and confirm whether |
This issue has been marked stale because it is tagged awaiting-info for 30 days with no activity. Remove the stale label or comment to prevent the issue being closed in 10 days. |
I get this about 4 or 5 times a day, a lot of the times it will be something where there are literally like 3 instances to rename in the same file, and it just fires off the loading indicator, and nothing happens. Other times it's super robust. Will try and find any rhyme or reason to it. |
I'm on previewLsp and I still have the same issue. LogsSLOW
FAST
|
This week I found a performance bug in the LSP server that may be related. The issue was a combination of a few things:
These things together can result in the server doing unnecessary work right when you'd want it to be doing other things (such as servicing a Ctrl+Click, or handling a file you've just opened). The fix for that has landed in Flutter's master branch. I wonder if anyone seeing these issues on is able to test whether temporarily switching to master seems to resolve this? (note: the first analysis of a project after changing branch will be slower, as the Flutter SDKs are seen for the first time). This appears to have helped for at least one user. |
Do you know which version of dart and dart-code might contain improvements around this issue? I'm seeing some pretty rough slowness on flutter 2.0.4, dart 2.12.2. renaming a symbol in a small file but a large codebase (80K+ lines of dart w/o codegen'd files, with codegen'd files 290K+ lines). Here's the analyzer logs, hopefully this helps: I performed a Note: renaming the symbol back to the original name took maybe 1 second.
Logs
|
@samandmoore are you able to reliably reproduce this? How big is your project? I'm still struggling to repro this. I've been trying on flutter_gallery and I've tried wiping out |
@DanTup I work on the same codebase as @samandmoore and am able to reliably reproduce extremely slow (sometimes infinite) interactions. Unfortunately it's made VSCode nearly impossible to use in some fashions (for instance, I can't CMD+click into definitions, I need to manually navigate by searching for them because the CMD+click just hangs). @samandmoore mentioned that for size, we're at about 80K lines of dart. Here are my logs from attempting a simple local variable rename. I hit the refactor hotkey (shift+f6 for me because I use Intellij key bindings) and things hung infinitely (was never able to rename). Gave up after like 30 seconds of waiting, and here are the logs: Logs
|
Ya if you use VSCode in daily use with Flutter, you will see this constantly. I very often would see it in new files that didn't even have any references, renaming a simple variable would just hang, sometimes not completing at all. It actually got so bad I ended up fearing renaming, and started opting for manual find and replaces if I new it was all in a single file. Eventually I just switched back to Android Studio, because it's just not a quality work environment when you are constantly sitting there waiting for these actions to complete. |
This sounds like this issue mentioned above, although it should be fixed in Flutter's beta (and newer) channels. Your logs suggest you're on 2.2.0-10.2, but I can't find exactly what hash that version that is - is it a recent build? Have you seen it recently? Your log only shows traffic to the server, nothing from it - which certainly makes it seem like the server is busy. Are you able to provide a more complete log, that includes the last things from the server (they will contain
It's interesting to hear the issue might not occur in Android Studio. Both VS Code and Android Studio are using the same underlying Dart language server. This suggests it may be specific to the LSP layer - I wonder whether anyone here that sees this is not using LSP (to verify, you can hover over the Dart/Flutter version number in the status bar and see whether it says "DAS" or "LSP"). If anyone is able to repro this on a project that's public, I might have more success reproducing it with a specific project and specific rename. |
Oh interesting, yes I can confirm that after 2000+ hrs in Android Studio, I've never seen this once. When in VSCode I would see it multiple times per day. For context though I am a very heavy user of refactoring, I constantly am making new classes, renaming classes, renaming fields. Coming from C# world I learned to be very aggressive with it, because Visual Studio was so rock solid, and have brought a similar workflow to dart. So I probably rename things 20+ times a day, when I'm actively building things out. The repro case is hard because I found it to be intermittent, like it wouldn't happen twice on the same var... or at least not regularly. I remember a common flow where I would create a new class (Widget), give it like 2 or 3 fields, try and rename one of the fields, and it just spins forever... this would happen a lot. Other times, on much more complex examples, it would be lightning quick. Drives ya crazy! |
@DanTup That's right, we switched to the latest beta release last week because folks were having such a hard time on 2.0.4 and there was speculation that performance fixes were in the beta releases. The revision we're running is https://github.com/flutter/flutter/tree/b5017bf8de877083978bfeb1874d236c3fc83029 (based on a I had actually noticed a massive improvement after switching to this beta release last week (and so did many other folks), but then this week folks are having serious issues again, and no one can identify anything that's changed between then and now. Also, the codebase is actually about ~288K lines if we include codegen'd lines. It's about 9 packages (some flutter plugins, some pure dart packages, and one big old app package that binds it all together). |
Oh! I think i have an idea as to what's happening, abstractly. I've noticed this a few times: I will be happily coding away taking advantage of the performance fixes in the flutter beta release (as you mentioned) and then upon opening some new file I will find that all my tooltips just say "Loading..." and never load and then cmd+click just never goes anywhere. It's as if the analysis server is either completely frozen or has silently died. I think that when I do cmd+shift+p and then So, I think that you're right and we need to get some logging of what was sent to the server before it became unresponsive. Also, is there a way to retrieve logs from the server itself? For instance, if the server crashed, where would we find those logs? |
Hoping this helps. In this case, I restarted the server like @samandmoore mentioned, hit refactor (rename), and it seemed to hang for 8-10 seconds, so I did another refactor (rename) and it worked almost instantly. Not sure if there are any useful logs here, but there is traffic from the server. Perhaps something in the initial traffic to the server is indicative of the problem with the initial hang? Logs
|
For me it takes 1 minute in first run and 1 - 3 seconds in consequent ones |
Repeating a request from above for anyone new that's commented here. For those that can reliably reproduce this, some things that may help:
I've seen this a few times, but then never been able to reproduce it (even if I subsequently clear |
Hey @DanTup I have an even larger project (monorepo with multiple Dart/Flutter projects and that takes minutes to execute a rename or a Go To Symbol in Workspace) but I cannot share any logs from that project instrumentation-go to symbol.log The same operations in Intellij are instant across both projects, and the project I shared the log from is a medium sized one. |
I would really like to work with you towards a resolution, so reach out any time with any further info you need... |
@6h4n3m there's an open issue at #4106 about the workspace symbol list (it's possible they have the same cause, but the fixes might end up being different). There have been some improvements made that might not be in stable yet (but would certainly be in beta).. I'd be interested to know whether you see a difference on the beta channel, and also how large your workspace is (in particular, how many folders have pubspec.yaml/analysis_options.yaml files). If you can post this info on #4106, it'll be easier to track data/logs for each item separately. Thanks! |
I found this issue today. I see there have been no comments for almost a year now and the above-mentioned issue is already closed. Is there any news? This issue has not as many thumbs up as the first upvoted one, but it is still the second in that rank. |
Unfortunately there isn't currently a lot of information in this issue to help debug. My comment above (#2231 (comment)) had some notes about helping track this down - if you're seeing this issue and can provide repro steps/project or log files when it happens, that may help debug. Although this issue has a lot of 👍 's and comments above, it's been quiet for a while (as you noted) so it's not clear if many people are still affected by this. I had personally seen the behaviour described here a few times in the past (but then struggled to reproduce with logs), but I don't recall seeing it for a very long time now. Quite a lot has changed since this issue was first opened (the original logs above are the original analysis server protocol and now everything is LSP). Perhaps it would be better to close this issue and open a new one with more specifics about the issue you're seeing (and if you post the link here, anyone in this thread that's still seeing it can add a 👍 that might help gauge how widespread the issue is now). @FMorschel - do you want to file a new issue with some more specifics and we'll close this one to focus on what we know is still a problem today? |
I'll try and see if I can reproduce it again and create a new issue with reproducible steps then. I do agree with you, this one can be closed. If I end up reproducing it, or anyone else, we can add a comment here so that everyone following this one can go to the new issue. |
sgtm - closing this one and we'll pick this up in new issue(s) with more recent info. |
Rename symbol (shortcut key F2) in my flutter projects is really slow. Not sure if flutter is relevant of if this is a general dart problem. I think it is a dart problem so I'm posting here. When I have syntax/build errors I find it common that rename never finishes, the "infinite progress" in VS Code just keeps spinning what seems to be forever.
If I create a brand new (flutter) project:
flutter create slow_refactor
and then open the project, let everything initialize, pub get packages and let that complete as well. After this I go to main.dart, rename title to myTitle. This takes ... 10? 15? seconds to complete. If I rename it to myTitle2 it takes a split second.Can I mitigate this issue somehow? It's really tedious to rename symbols and most often I just hit replace all feature instead because I'm convinced that the rename won't work. Rename is such a common (simple) refactor that I expect it to work at all times.
I can't find any known issues regarding this but I know that other members in my team have the same issue.
I'm running Windows 10, stable VS Code, flutter 1.13 and 1.14 (beta and master), dart 2.8.0-dev.3.0. My computer specs are category "great" so this is not due to slow cpu, disk or memory issues.
The text was updated successfully, but these errors were encountered: