Skip to content

IntelliSense slow or unresponsive forced to kill powershell to force it to work. #1256

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

Closed
ebmarquez opened this issue Apr 3, 2018 · 25 comments
Milestone

Comments

@ebmarquez
Copy link

ebmarquez commented Apr 3, 2018

System Details

  • Operating system name and version:
Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.16299.0 Microsoft Windows NT 10.0.16299.0

  • VS Code version: 1.21.1
  • PowerShell extension version: 1.6.0
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.16299.251
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.251
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

code -v

1.21.1
79b44aa704ce542d8ca4a3cc44cfca566e7720f1
x64

$pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      6      0      0

code --list-extensions --show-versions

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.16299.251
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.251
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

### Issue Description
IntelliSense is slow or unresponsive when using powershell in the editor.  
To get it to work correctly again, I have to kill and restart powershell in Vscode to force it to work again.

### Attached Logs

logs.zip

@TylerLeonhardt
Copy link
Member

Hi there, thanks for the report. Can you please attach the logs (instructions: https://github.com/powershell/vscode-powershell#2-capture-verbose-logs-and-send-them-to-us)

And also give me some details on how big your workspace is and how big your file is that's giving you slow intellisense?

@ebmarquez
Copy link
Author

it shows the logs are already attached.
logs.zip
My PSM1 file is 6704 lines

workspace size
All files which includes Jinja2, C#, Python, Powershell:

(Get-ChildItem .\DeploymentToolKit\ -Recurse).count
7914

Powershell related files:

((Get-ChildItem .\DeploymentToolKit\ -Recurse -Filter "*.ps?1").FullName).count
38

@lushibi
Copy link

lushibi commented Apr 4, 2018

I have a problem that the intellisense does not work at all, until I exit the "PowerShell Integrated Console" which is opened by vscode automatically.

image

@ghost
Copy link

ghost commented Apr 5, 2018

I confirm the behaviour, killing the Integrated Console in VSCode made the IntelliSense work back again.

@ghost
Copy link

ghost commented Apr 9, 2018

It seems that the following "old" line in my user settings was messing up things.
"powershell.powerShellExePath": "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe"

Once removed, IntelliSense is working fine and quickly again.

@TylerLeonhardt
Copy link
Member

@ebmarquez oops missed the logs. Thanks for the extra info!

@TylerLeonhardt
Copy link
Member

This is one of the more important perf bugs that I've been hearing about.

@rayholtz
Copy link

I also can confirm that killing the Powershell Integrated Console makes Intellisense work again. I have VScode v1.22.1.

@rjmholt rjmholt added this to the 2.0.0 milestone May 24, 2018
@ChrisLynchHPE
Copy link

ChrisLynchHPE commented Jun 1, 2018

Yes, killing the PIC does make Intellisense "work" again. However, really need variable and function lookup Intellisense provides when the PowerShell session is running. I really hope performance can dramatically improve.

Data points about my dev system:

[PS] ...\MyDir> code -v
1.23.1
d0182c3417d225529c6d5ad24b7572815d0de9ac
x64
[PS] ...\MyDir> $pseditor.EditorServicesVersion
[PS] ...\MyDir> code --list-extensions --show-versions
alefragnani.Bookmarks@0.19.1
alefragnani.pascal@0.11.0
humao.rest-client@0.18.4
idleberg.innosetup@1.0.3
mechatroner.rainbow-csv@0.3.0
mohsen1.prettify-json@0.0.3
ms-python.python@2018.4.0
ms-vscode.csharp@1.15.2
ms-vscode.github-issues-prs@0.9.0
ms-vscode.PowerShell@1.7.0
robertohuertasm.vscode-icons@7.23.0
Shan.code-settings-sync@2.9.2
tariky.easy-snippet-maker@0.0.6
tht13.html-preview-vscode@0.1.1
wayou.vscode-todo-highlight@0.5.12
[PS] ...\MyDir> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.81
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.81
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Also, my workspace includes both a PowerShell module (1 PSM1) and a C# library. The PSM1 is ~2.8MB, and contains 33585 lines (~45% of those lines are blank).

@cpdohert
Copy link

cpdohert commented Aug 9, 2018

code -v

1.25.1
1dfc5e557209371715f655691b1235b6b26a06be
x64

$pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      8      2      0

code --list-extensions --show-versions

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.165
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.165
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I was having this problem consistently and found a possible cause.

I was developing a PowerShell Module for internal use. An old version of the module which I'd forgotten about was installed in C:\Users\cpdohert\Documents\WindowsPowerShell\Modules\MyModule\MyModule.psm1

I was also regularly running Import-Module C:\Users\cpdohert\Documents\repos\MyModule\MyModule.psm1 -Force in a PowerShell ISE window outside VS Code.

When I deleted the old C:\Users\cpdohert\Documents\WindowsPowerShell\Modules\MyModule\MyModule.psm1 file, IntelliSense began working speedily again.

Also, the slowdown only occurred once I upgraded to 1.8.2. Under 1.8.1 this configuration did not cause any problems.

@OneSpecialPeg
Copy link

Experiencing the same issues. Killing the terminal resolved the issue for me but I don't have old modules or packages.

@rjmholt
Copy link
Contributor

rjmholt commented Sep 18, 2018

Two things that you can try for now are:

We've been chipping away at performance issues recently, although there's still a lot of work to be done. But hopefully you'll experience some improvement in the next release. Here are the recent PRs:

The bigger performance gains are ones that require either changes in PSScriptAnalyzer or architectural changes in EditorServices, so we've been trying to fix those the "right" way, trying not to break too much.

@ebmarquez
Copy link
Author

ebmarquez commented Sep 18, 2018 via email

@spicydll
Copy link

For me, the intellisense is very responsive until I add a function or an additional function to my script. To work around this, I comment out all functions I'm not currently working on:

<#function Invoke-StuffThatImNotWorkingOn {
    # ...
}
#>

Write-Host 'Yay! Intellisense aint garbage here!'

Even having a single function slows intellisense responsiveness. It feels like the intellisense is processing every function one at a time by spawning a new instance without multi-threading.

This work around is not great as you have to uncomment everything when you save and want to test (I've only used it on relatively small files). However, it exponentially increases the intellisense speed.

@TylerLeonhardt
Copy link
Member

Two things that you can try for now are:

I'd like to ask everyone on this thread if there was one out of these two that helped a lot or if both helped a lot. This will help us understand the situation

@mattpwhite
Copy link

Those help, but performance is still so bad that the extension borderline does not work. I've strongly considered removing it and just going back to plain PowerShell-oblivious token completion.

From some casual dotTrace profiling, the performance issues that persist with those features disabled appear related to auto-formatting, having a significant number of modules installed, PowerShell's general slowness at loading modules, and the lack of cancellation support in PSES (once it falls behind, you might as well kill it, it's not going to catch up).

Even with script analysis disabled, PSA is still loaded for formatting purposes, and still likes to go off and effectively import everything in PSModulePath. For people running on Windows (which ships with dozens of modules), that have RSAT installed (takes us over 100) and that have a lot of internal and third party modules installed, importing everything in PSModule path is a multi-minute affair. get-module -ListAvailable | measure counts 248 modules for me, about evenly split between the OS and our internal module repo. Literally importing all of those took 202 seconds when I clocked it just now.

A ~minute long trace I took while the extension was out to lunch (and burning a core relentlessly) shows the following. Again, this is with script analysis and code lens off.

image
image
image

So, it's the PSA formatter trying to get command info, which forces modules loads, which takes roughly forever. The files I actually have open only reference commands from a handful of modules that would take only a couple seconds to load, but it seems like it's loading everything? That or it's loading the same things over and over.

@SydneyhSmith
Copy link
Collaborator

@mattpwhite thanks for all this information it is super helpful to us! What setting are you using for auto-formatting (format on type, or format on save)...would you also please open an issue in the Script Analayzer repo as formatting is done by Script Analyzer so the improvements will happen there.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 25, 2019

@mattpwhite Thanks for the really great analysis!

@mattpwhite
Copy link

Just format on paste (and occasional explicit format selection). Formatting is far too buggy to apply to whole files. I usually end up with everything jammed up on the left without any indentation if I let it do a whole file. As if it’s decrementing the appropriate indent level more often than it’s incrementing it. I don’t trust it to do much more than line up a hashtable. I know I should probably log issues for that too. It’s pretty tedious to work out a minimal reproducer given the perf issues, but I’ll try to log those and this issue with PSA.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 26, 2019

It's probably easier to repro directly with something like:

Import-Module PSScriptAnalyzer -Version 1.18.1
Invoke-Formatter -ScriptDefinition @'
<script>
'@ # Or alternative gc -raw ./file.ps1 | invoke-formatter

Amongst a few other things, we're working on how to host PSScriptAnalyzer better and hope to see some improvements there. Unfortunately, PSScriptAnalyzer has a few rough spots that are hard for us to contain, but because it's part of the default experience, people expect it. I'm also contributing to PSSA when I find time, particularly in the performance area, so armed with the information you've provided I'm hoping we can find some real improvements here.

@Hypernut
Copy link

Any news on this issue? Its very annoying... Thanks!

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 14, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Dec 15, 2019

@Hypernut we're planning to release the next preview extension version next week, which you should try to see whether it improves your intellisense experience. We're planning on stabilising that in January. There's a summary of the work going in here.

@ebmarquez
Copy link
Author

Yes, please make some progress on this. It's crazy how bad this experience really is. I restart vscode multiple times a day because its so bad.

@rjmholt
Copy link
Contributor

rjmholt commented Dec 15, 2019

@ebmarquez try out the powershell-preview extension if you'd like to evaluate the progress so far

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 17, 2019
@SydneyhSmith
Copy link
Collaborator

Going to close this as a result of the major architectural changes we made in the omnisharp port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests