-
Notifications
You must be signed in to change notification settings - Fork 510
Delays in running PowerShell code or F8 not working at all #1769
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
Comments
Thanks for reporting this @atyourservers ! It would be really helpful if you could provide logs if this happens again so that we can better diagnose the issues--instructions for how to do this are here |
@SydneyhSmith please find the logs attached. I had to redact them quite a bit. Tested it with some test files. Started around 9:20 until 9:35, then had some calls and if I remember correctly, I later tried to run a few more commands, closed everything, redacted the logs and here you go. The issue occurred various times, so hopefully the logs are helpful. Looking forward to hearing from you. |
@atyourservers thanks for providing the logs that always helps! There is nothing obvious about your environment that would be causing issues but we have had other reports of performance issues that we are hoping to solve soon and this is likely related. |
When I just paste code in the integrated PowerShell window it runs straight. It only happens when I try to execute code from the editor window by pressing F8 or via right click -> Run Selection. It's like there is a process of some sort which tries to do something to the code, such as validation, which takes minutes to run. I thought this could be the ScriptAnalyzer, but disabling it didn't have any effect on the issue. Seeing that it sometimes does work fine for a few minutes maximum, it's like a process gets stuck sometimes in the background. More people here are experiencing the same issue. I love Visual Studio Code and the PowerShell extension, but this issue is forcing us to use different tools. Hopefully it can be tackled soon. |
@atyourservers some people have had success with associating performance issues to code lens, disabling that might be something worth trying. More likely this is due to architectural challenges that we are hoping to resolve soon. |
I've had this same issue for at least a year with VS Code. As I type this, I'm waiting for an F8 command to run: $date = get-date It's been nearly 10 minutes, so now I'm going to have to close and re-open the terminal window, losing all of the content in memory that I've been working on. This happens at least once a day. It is incredibly frustrating that this software is so unstable while also being touted as the obvious replacement for PowerShell ISE. ISE has been very stable since 1.0. |
@atyourservers Looking at your log file, it seems that SymbolReference CodeLens comand resolve results are taking a long time but those requests are supposed to run async (in another runspace) and return results "out-of-band":
The
Does this correspond to one of your lengthy F8 atttempts? BTW the evaluate above that takes ~88 secs shows how this request is executed async:
|
The codeLens/resolve for symbol references appears to run synchronously - blocking all other LSP messages until the CA request finishes. These are consecutive LSP JsonRpc request/response messages pairs. Check out the timestamp diffs:
Between index 46 and 1106, we seem to be opening a lot of files:
There is a 1 min 40 sec gap between index 47 and 48. There is a 2 min 35 sec gap between index 53 and 54. Index 53 indicates script analysis has finished but it doesn't get a chance to send VSCode the diagnosit results until index 1109, almost three minutes later. This is also puzzling, we get the request to resolve the codelens command here and begin symbol reference analysis:
but then there are only code analysis messages:
Then after than 2 min 35 sec gap, we start back with the symbol reference analysis:
So the question is, why the gap? Does this have something to do with the file being on the BTW the message from index 47 comes from the |
So are folks still seeing issues like this if you disable code analysis with the setting:
I'm beginning to wonder if this is an issue with the symbol reference code lens provider or some interaction between it and the Pester code lens provider. |
@SydneyhSmith Disabling CodeLens using
@rkeithhill I'm not opening a lot of files... I don't open more than six files at a time. It seems like in the background a lot of files are being opened, maybe by CodeLens...!? But it's not me doing it! These files are just there in my repository, that's all. Sounds like you found part of the issue here...
@rkeithhill I've just fixed a typo in my opening post, where I wrote |
Just experienced a delay when running two simple |
Disabling Code Lens has really sped up my development of PowerShell in VS Code, not just running code via F8. This became really noticeable around v1.31 of VS Code for me, too. Unfortunately, it hasn't helped me with debugging problems I've been having since v1.31 of VS Code. (The debugger won't attach around the 3rd debug run, and attempting to stop the debug process results in a |
I would just like to add, I have been running with codelens disabled for over a year #1326 I still see performance issues, . . . and freezes. . . I can repro this 100% of the time. I will have to also add/try: "powershell.scriptAnalysis.enable": false At this stage, we have no formatting or code analysis in the extension... so hopefully we can find the root cause of these issue, since they are tools that we would prefer to have enabled. . . This is an ongoing issue, since Code/PS Extension was first released. |
@brwilkinson The code analysis perf issues are due to PSScriptAnalyzer perf. There is a release coming out of PSSA that will improve the perf of PSSA. There is also a PR that @glennsarti is working on that will reduce the scope of files being analyzed for symbol references. That should help some as well. If you are running into perf issues with both code lens and code analysis disabled, please attach log files. That is our primary way to track the root cause of perf issues unless we have solid way to repro perf issues. |
Thanks @rkeithhill . . . I am trying out: "powershell.scriptAnalysis.enable": false . . . for now and will share any feedback... I'll keep an eye on the updates. . . |
okay disabling 'scriptAnalysis' definitely helps . . . however the freezes have not gone all together. I will share some more logs here... |
@brwilkinson Can you update to the latest 1.18.0 release of PSScriptAnalyzer and re-enable codeAnalysis. This version of PSSA is significantly more performant. |
Thanks @rkeithhill I have installed 1.18.0, will give it a run. . . keep you posted. |
@rkeithhill Looking good so far. . . Thank you. . . It's still a definite no for Codelens. . . however for now with that disabled and psscriptanalyzer updated the following are working pretty well . . .
I'll provide another update once I actually write some proper code, rather than just running some code and tests. . . however there is definitely a major improvement without any doubt. |
Thanks for the feedback. Yeah, I wouldn't expect any change for the reference code lens as that is implemented separately. I think there will be a feature in the next version to allow you to exclude folders from reference analysis. That might help if you have dirs (like output or import dirs) that don't need to be analyzed. |
Going to close this as a duplicate of #1326 |
I tried disabling CodeLens, issue still persists. |
When selecting PowerShell code in Visual Studio Code and running it either via right click -> Run Selection or by pressing F8, it sometimes takes a long time for the code to run and sometimes it doesn't run at all, whereas other moments (rarely unfortunately) the code runs straight away. There is no other keybinding to F8. It doesn't matter how much code is selected either. It can be as little as: $test = 'Test'. I have hardly any modules loaded; the default Windows modules, AzureRM and AzureAD. I have tried with ScriptAnalyzer disabled ("powershell.scriptAnalysis.enable": false), but that didn't help. The issue is so bad currently, that I just copy/paste the code into the integrated PowerShell window to run it, which works fine, but which is a pain when you need to run parts which consist of multiple lines of code.
Visual Studio Code:
Version: 1.31.1 (system setup)
Commit: 1b8e8302e405050205e69b59abb3559592bb9e60
Date: 2019-02-12T02:20:54.427Z
Electron: 3.1.2
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 6.3.9600
PowerShell extension: 1.11.0
The text was updated successfully, but these errors were encountered: