-
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 analyze" and analysis server sometimes hang for ~30seconds when analysis server plugins are enabled #55621
Comments
If VS Code initial analysis is slow even after it's been analyzed before, it would be interesting to see a complete instrumentation log for that period.
Please also include:
|
analyzer-copy.txt |
I also recorded a video to showcase the problem |
@nank1ro thanks - taking a look. But could you confirm if the issue occurs if you disable the I don't know the cause of those issues (including whether it's a custom_lint issue or analyzer issue), but it may help narrow down the issue. |
I disabled custom_lint and become much faster. Maybe I should update it on |
@nank1ro does "much faster" mean "faster but still quite slow" or did it solve the issue entirely? I couldn't reproduce the issue but I wonder if we have different versions of some dependencies - are you able to provide a copy of the |
The issue is solved. Now I activated again custom_lint then upgraded it from the version 0.5.7 to 0.6.4 and everything works smooth. |
@nank1ro great, I'll close this then. I am still interested in your |
Here are the files. |
Thanks! Unfortunately even with those files I don't seem to be able to repro the issue. I tried pinning analyzer with a dependency override to 5.12.0 suspecting maybe this upgrade of the package may be what fixed the problem. Everything is still very fast though - around 5-10s for a first analysis after I wipe out the I also couldn't see any obvious paths in code where we might be waiting for plugins where the delay was in the logs here (around the time we're building analysis contexts). Maybe @scheglov or @bwilkerson have more ideas what could have gone wrong here (although it might not be worth spending too much effort on if plugin changes might mean changes to how these are loaded in future). |
@DanTup Here is what I get on Flutter stable:
This seems extremely strange - I just sit there at run the same command without changing any files and randomly analysis time skyrockets. Maybe analyzer folks can recognize the problem? |
@mraleph were you using the pubspec.lock's from above or a clean solve? I didn't realise it was this intermittent, I'll do some more testing. Edit: Turns out I can repro this from the CLI using Stable dart (~30s reliably) but using a bleeding-edge build, it's around 5-10s. It's possible this is something that was already discovered and fixed, but I'll try to confirm. |
I added more logging to the server and reproduced the issue:
It appears the issue here is that for plugins, we end up calling Indeed, if I run If I run it with
Unfortunately although it seems to making many attempts for something here, it doesn't contain any information why (are the requests failing?). So I guess there are two issues here - the known issue that the server startup is blocked on network access for Pub, but also it seems like something is wrong for Pub to be hanging for ~30s when it appears to have completed. I'll file an issue in pub about the latter (edit: opened dart-lang/pub#4256). |
@DanTup aren't the dependencies cached? |
It turns out the issue here was an unclosed That issue has been recently fixed (in dartdev) and cherry-picked to beta (#55402). As part of the analyzers plugin changes we should ensure we don't block like this on running external processes. In the short-term, I'm going to open a change to at least make this process execution visible in the instrumentation log to make it easier to know when this is the issue.
The analyzer isn't calling Pub directly here, it's running Closing this issue as the main issue here has been resolved (as of current beta). There's still #49934 open tracking that plugin support currently depends on network access. |
…s in instrumentation log This will help identify issues like #55621 in future from the logs without needing to repro. Before, there was just a gap in the logs that wasn't obvious. A sample log looks like: ``` 1715080652096:Req:{"jsonrpc"::"2.0","id"::2,"result"::null,"clientRequestTime"::1715080652091} 1715080652253:Info:Running "pub upgrade" in "C::\Users\danny\AppData\Local\.dartServer\.plugin_manager\723cb7b2bec3011e09cd16421250ff7a\analyzer_plugin" 1715080653311:Info:Running "pub upgrade" took 0::00::01.057950 1715080653393:Res:{"id"::3,"jsonrpc"::"2.0","method"::"window/workDoneProgress/create","params"::{"token"::"ANALYZING"}} ``` (This was the only instance of `Process.runSync` in the server) Change-Id: I2ccc5a7c538ae7a236a76df020c59014982a2e19 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365602 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
User @nank1ro reported they see 30s timings when analyzing https://github.com/nank1ro/flutter-shadcn-ui repo from command line using
dart analyze
. Doingdart analyze
twice shows the same ~30s timings on both runs - which is unexpected. User is using M1 2020 Mac. They also report bad IDE experience where it takes multiple minutes to finish analysis on large projects.I have asked them to purge
~/.dartServer
and that changed the picture for CLI run: second run took only 2s, which is more inline with what I would have expected. This did not translate to IDE experience improvements - closing and reopening IDE (VS Code) still suffers from long initial analysis.I wonder if the analysis cache got into some wrong state somehow? Is there a way to diagnose this?
/cc @scheglov @DanTup
Twitter thread is https://twitter.com/nank1ro/status/1785963202062237773
The text was updated successfully, but these errors were encountered: