Skip to content
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

Auto-completion fails due to performance issues #2522

Closed
rkeithhill opened this issue Mar 5, 2020 · 41 comments · Fixed by PowerShell/PowerShellEditorServices#1238
Closed

Comments

@rkeithhill
Copy link
Contributor

rkeithhill commented Mar 5, 2020

System Details

System Details Output

### VSCode version: 1.42.1 c47d83b293181d9be64f27ff093689e8e7aed054 x64

### VSCode extensions:
abusaidm.html-snippets@0.2.1
bierner.github-markdown-preview@0.0.2
bierner.markdown-checkbox@0.1.3
bierner.markdown-emoji@0.0.9
bierner.markdown-preview-github-styles@0.1.6
bierner.markdown-yaml-preamble@0.0.4
DavidAnson.vscode-markdownlint@0.34.0
DotJoshJohnson.xml@2.5.0
eamodio.gitlens@10.2.1
EditorConfig.EditorConfig@0.14.4
eg2.tslint@1.0.44
Mikael.Angular-BeastCode@8.1.2
ms-dotnettools.csharp@1.21.13
ms-python.python@2020.2.64397
ms-vscode-remote.remote-containers@0.101.1
ms-vscode-remote.remote-ssh@0.49.0
ms-vscode-remote.remote-ssh-edit@0.49.0
ms-vscode-remote.remote-ssh-explorer@0.49.0
ms-vscode-remote.remote-wsl@0.42.3
ms-vscode-remote.vscode-remote-extensionpack@0.19.0
ms-vscode.cpptools@0.26.3
ms-vscode.powershell@2020.3.0
ms-vscode.vscode-typescript-tslint-plugin@1.2.3
msjsdiag.debugger-for-chrome@4.12.6
msjsdiag.debugger-for-edge@1.0.14
robinbentley.sass-indented@1.5.1
sibiraj-s.vscode-scss-formatter@1.4.3
SimonSiefke.svg-preview@2.8.3
twxs.cmake@0.0.17
vsls-contrib.gistfs@0.0.61
wayou.vscode-todo-highlight@1.0.4
yzhang.markdown-all-in-one@2.7.0


### PSES version:

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

Auto-complete was working for about 5 minutes into editing a small script (220 lines) but now it has wedged.

Expected Behaviour

Auto-complete should not ever stop working - in an ideal world. :-)

Actual Behaviour

I get the dreaded "Loading..." message for at least a minute before I give up:

VSCodePSAutoCompleteWedge.zip
1583432852-d0e516fc-13f8-444b-877f-cecf115455871583432271941.zip

Attached Logs

Follow the instructions in the troubleshooting docs
about capturing and sending logs.

1583432852-d0e516fc-13f8-444b-877f-cecf115455871583432271941.zip

@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 5, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Mar 5, 2020

Does Ctrl+C help?

@rkeithhill
Copy link
Contributor Author

In the integrated terminal? For some reason, the integrated terminal is not appearing in my list of terminals.

@rkeithhill
Copy link
Contributor Author

Also, seems my PS Session is still using RC.3 even though I upgraded to the GA release.

@rjmholt
Copy link
Contributor

rjmholt commented Mar 5, 2020

It's probably defaulting to preview. Try switching to PowerShell (x64)

@rkeithhill
Copy link
Contributor Author

OK, now on PS 7 GA and have PSIC displaying. I had done some experimenting with settings a while back and apparently set showOnStartup to false. Fixed.

@rjmholt
Copy link
Contributor

rjmholt commented Mar 5, 2020

Are you running anything in the time before the completions fail?

@rjmholt
Copy link
Contributor

rjmholt commented Mar 5, 2020

I'm getting sluggish completions, but haven't been able to repro this yet

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Mar 5, 2020

No, not running anything. I can do a develop reload window and try auto-completion and initially, it works OK but gets slower. Some context, these couple of PS scripts are in a project that houses an Electron app with several Angular lib projects. That's six node_modules directories and 295,000 files.

@rjmholt
Copy link
Contributor

rjmholt commented Mar 5, 2020

That's six node_modules directories and 295,000 files.

Wow. Hmm yeah I suspect this is related to that. I think there might be a simple fix here that we've been overlooking for a while, where we need to filter out bad files...

I'm thinking of #1256 (comment)

@rjmholt
Copy link
Contributor

rjmholt commented Mar 5, 2020

That just encourages me to get back to work on PSScriptAnalyzer...

@SydneyhSmith SydneyhSmith added Area-IntelliSense Issue-Performance Something's slow. and removed Needs: Triage Maintainer attention needed! labels Mar 5, 2020
@mrboring
Copy link

mrboring commented Mar 8, 2020

No, not running anything. I can do a develop reload window and try auto-completion and initially, it works OK but gets slower. Some context, these couple of PS scripts are in a project that houses an Electron app with several Angular lib projects. That's six node_modules directories and 295,000 files.

I'm also getting a slow down on auto-complete. Even with a project containing only a few files.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 8, 2020
@SeeminglyScience
Copy link
Collaborator

@rjmholt do you know which release of PackageManagement had the dead lock fix? And do you know if that's included with anything?

I think I've seen it recently, but didn't look into it past confirming the thread was stuck getting tab completion for Install-Package. Might just be my environment though.

@rjmholt
Copy link
Contributor

rjmholt commented Mar 9, 2020

do you know which release of PackageManagement had the dead lock fix?

1.4.5 I believe

And do you know if that's included with anything?

So far as I know, it's only included with PowerShell.

But that is a good recommendation. Try updating PackageManagement if you can

@SeeminglyScience
Copy link
Collaborator

Yep I had a copy at the user level that was 1.4.4, that was getting imported instead of the 1.4.6 at the machine level. Not sure why, I could have sworn it would pull the latest.

It may be worth considering including PackageManagement with the extension 😕

@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

It may be worth considering including PackageManagement with the extension 😕

Hmmm, that's an idea, although we'd need to import it differently the way the module path works.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 10, 2020

Curious to know if the others in this thread have an old version of PackageManagement hiding. @rkeithhill @mrboring

@mrboring
Copy link

@TylerLeonhardt, I have two, one is for 5.1:

> get-module PackageManagement -ListAvailable | fl *

LogPipelineExecutionDetails : False
Name                        : PackageManagement
Path                        : C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.psd1
ImplementingAssembly        : 
Definition                  : 
Description                 : PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web.
                               It is a manager or multiplexor of existing package managers (also called package providers) that unifies Windows package management with a single Windows PowerShell interface. With PackageManagement, you can do the following.
                                - Manage a list of software repositories in which packages can be searched, acquired and installed
                                - Discover software packages
                                - Seamlessly install, uninstall, and inventory packages from one or more software repositories
Guid                        : 4ae9fd46-338a-459c-8186-07f910774cb8
HelpInfoUri                 : https://go.microsoft.com/fwlink/?linkid=2113634
ModuleBase                  : C:\program files\powershell\7\Modules\PackageManagement
PrivateData                 : {PSData}
ExperimentalFeatures        : {}
Tags                        : {PackageManagement, PSEdition_Core, PSEdition_Desktop, Linux…}
ProjectUri                  : https://oneget.org/
IconUri                     : 
LicenseUri                  : 
ReleaseNotes                : ## 1.4.6
                              - Update `HelpInfoUri` to point to the latest content
                              
                              ## 1.4.5
                              - Bug fix for deadlock when getting parameters in an event
                              
                              ## 1.4.4
                              - Bug fix when installing modules from private feeds
                              
                               ## 1.4.3
                              - Another bug fix when registering repositories with PowerShellGet
                              
                              ## 1.4.2
                              - Bug fix for passing credentials from PowerShellGet when registering repositories
                              
                              ## 1.4.1
                              - Bug fix for using credential provider installed in Visual Studio
                              
                              ## 1.4
                              - Allow credential persistance for registering private repositories and finding or installing packages from those repositories
                              
                              ## 1.3.2
                              - Enable bootstrap on PSCore
                              - Bug fix to run on .NET Core 3.0
                              
                              ## 1.3.1
                              - Targets net452 and netstandard2.0 instead of net451, netcoreapp2.0, and netstandard1.6
                                          
                              ## Previous releases are not included in this Changelog
RepositorySourceLocation    : 
Version                     : 1.4.6
ModuleType                  : Script
Author                      : Microsoft Corporation
AccessMode                  : ReadWrite
ClrVersion                  : 4.0
CompanyName                 : Microsoft Corporation
Copyright                   : (C) Microsoft Corporation. All rights reserved.
DotNetFrameworkVersion      : 
ExportedFunctions           : {}
Prefix                      : 
ExportedCmdlets             : {[Find-Package, Find-Package], [Get-Package, Get-Package], [Get-PackageProvider, Get-PackageProvider], [Get-PackageSource, Get-PackageSource]…}
ExportedCommands            : {[Find-Package, Find-Package], [Get-Package, Get-Package], [Get-PackageProvider, Get-PackageProvider], [Get-PackageSource, Get-PackageSource]…}
FileList                    : {}
CompatiblePSEditions        : {}
ModuleList                  : {}
NestedModules               : {}
PowerShellHostName          : 
PowerShellHostVersion       : 
PowerShellVersion           : 3.0
ProcessorArchitecture       : None
Scripts                     : {}
RequiredAssemblies          : {}
RequiredModules             : {}
RootModule                  : PackageManagement.psm1
ExportedVariables           : {}
ExportedAliases             : {}
ExportedDscResources        : {}
SessionState                : 
OnRemove                    : 
ExportedFormatFiles         : {C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.format.ps1xml}
ExportedTypeFiles           : {}

LogPipelineExecutionDetails : False
Name                        : PackageManagement
Path                        : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.psd1
ImplementingAssembly        : 
Definition                  : 
Description                 : PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web. 
                               It is a manager or multiplexor of existing package managers (also called package providers) that unifies Windows package management with a single Windows PowerShell interface. With PackageManagement, you can do the following. 
                                - Manage a list of software repositories in which packages can be searched, acquired and installed 
                                - Discover software packages 
                                - Seamlessly install, uninstall, and inventory packages from one or more software repositories
Guid                        : 4ae9fd46-338a-459c-8186-07f910774cb8
HelpInfoUri                 : https://go.microsoft.com/fwlink/?linkid=392040
ModuleBase                  : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1
PrivateData                 : {PSData}
ExperimentalFeatures        : {}
Tags                        : {PackageManagement}
ProjectUri                  : https://oneget.org/
IconUri                     : 
LicenseUri                  : 
ReleaseNotes                : 
RepositorySourceLocation    : 
Version                     : 1.0.0.1
ModuleType                  : Binary
Author                      : Microsoft Corporation
AccessMode                  : ReadWrite
ClrVersion                  : 4.0
CompanyName                 : Microsoft Corporation
Copyright                   : (C) Microsoft Corporation. All rights reserved.
DotNetFrameworkVersion      : 
ExportedFunctions           : {}
Prefix                      : 
ExportedCmdlets             : {[Find-Package, Find-Package], [Get-Package, Get-Package], [Get-PackageProvider, Get-PackageProvider], [Get-PackageSource, Get-PackageSource]…}
ExportedCommands            : {[Find-Package, Find-Package], [Get-Package, Get-Package], [Get-PackageProvider, Get-PackageProvider], [Get-PackageSource, Get-PackageSource]…}
FileList                    : {}
CompatiblePSEditions        : {Desktop}
ModuleList                  : {}
NestedModules               : {}
PowerShellHostName          : 
PowerShellHostVersion       : 
PowerShellVersion           : 5.1
ProcessorArchitecture       : None
Scripts                     : {}
RequiredAssemblies          : {}
RequiredModules             : {}
RootModule                  : Microsoft.PowerShell.PackageManagement.dll
ExportedVariables           : {}
ExportedAliases             : {}
ExportedDscResources        : {}
SessionState                : 
OnRemove                    : 
ExportedFormatFiles         : {C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.format.ps1xml}
ExportedTypeFiles           : {}

System Details

### VSCode version: 1.42.1 c47d83b293181d9be64f27ff093689e8e7aed054 x64

### VSCode extensions:       
alefragnani.Bookmarks@11.0.0 
eamodio.gitlens@10.2.1       
Ionide.Ionide-FAKE@1.2.3     
Ionide.Ionide-fsharp@4.6.4   
Ionide.Ionide-Paket@2.0.0    
mohsen1.prettify-json@0.0.3  
ms-dotnettools.csharp@1.21.13
ms-vscode.powershell@2020.3.0


### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PSModulePath

C:\Users\<REMOVED>\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\7\Modules
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Data\PowerShell\Modules
c:\Users\<REMOVED>\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules
C:\Data\PowerShell\Modules

@SeeminglyScience
Copy link
Collaborator

@mrboring

C:\Program Files (x86)\WindowsPowerShell\Modules

Huh, that's weird. What's [Environment]::Is64BitProcess? All of your paths are x64 except this one, might be nothing, but is strange.

@mrboring
Copy link

@SeeminglyScience

 [DBG]:> [Environment]::Is64BitProcess

True

Also:

[DBG]:> Get-ComputerCPU         

ComputerName              : <REMOVED>
Name                      : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
DeviceID                  : CPU0
Caption                   : Intel64 Family 6 Model 158 Stepping 9
CurrentClockSpeed         : 2904
MaxClockSpeed             : 2904
ProcessorID               : <REMOVED>
ThreadCount               : 8
Architecture              : 9
Status                    : OK
LoadPercentage            : 10
Manufacturer              : GenuineIntel
NumberOfCores             : 4
NumberOfEnabledCore       : 4
NumberOfLogicalProcessors : 8


 [DBG]:> Get-ComputerOperatingSystem

ComputerName     : <REMOVED>
Caption          : Microsoft Windows 10 Pro
Manufacturer     : Microsoft Corporation
OSArchitecture   : 64-bit
OSLanguage       : 1033
OSProductSuite   : 256
InstallDate      : 01/06/2019 20:11:17
LastBootUpTime   : 06/03/2020 10:42:14
LocalDateTime    : 10/03/2020 12:15:11
Version          : 10.0.18363
SerialNumber     : <REMOVED>
BootDevice       : \Device\HarddiskVolume2
WindowsDirectory : C:\WINDOWS
CountryCode      : 44

@SeeminglyScience
Copy link
Collaborator

Sort of a shot in the dark, but maybe worth changing that entry in your $env:PSModulePath to C:\Program Files\WindowsPowerShell\Modules.

@mrboring
Copy link

@SeeminglyScience Thanks for the suggestion. I'll give that a go and let you know how I get on.

That said, the slow down in auto-complete has only started recently. The PSModulePath has not changed for some time.

@mrboring
Copy link

@SeeminglyScience I've done the change you suggested and it doesn't make a difference.

I've had a bit more time to do testing and find that the issue increases the longer you work on a file. I had a test file with 35 line and by the last line there was a small delay (upt to three seconds, not there on earlier lines). If I switch to another file, do some editing, switch back to the original file, the performance is OK.

In my (limited) testing I've not experienced long delays. Maybe that's related to me updating VS Code to 1.43.0, or maybe I've not done enough testing. Previously, after waiting more than ten seconds, I would simply type the required text.

The delay I had in testing was relating to Measure-Object. I typed measure-, auto-complete did not kick in, so I did Ctrl+Space. It took about three seconds for the list of suggestions to appear. I created a new document and did the same. The list of suggestions appeared instantly after I typed measure-. I've experienced this issue with other commands, so it's not related to Measure-Object. I just wanted to give an example.

I'm trying to create a reproducible test that I can post here. Not easy on this type of issue.

@mrboring
Copy link

mrboring commented Mar 11, 2020

I've just experienced auto-complete not working. After about 30 seconds I gave up and typed the text. At the same time, I noticed that document formatting stopped working.

@rjmholt rjmholt changed the title After a little while, auto-complete completely stops working Auto-completion fails due to performance issues Mar 11, 2020
@SeeminglyScience
Copy link
Collaborator

@mrboring try this:

Import-Module PackageManagement -PassThru

Check which version you're getting when you do that

@stevenebutler
Copy link

stevenebutler commented Mar 30, 2020

This issue has regressed for me with the latest preview release 2020.3.1.
auto-complete doesn't work at all anymore. Reverting the extension to 2020.3.0 has it working again.

Probably best to track in #2590 which i've just found.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 30, 2020
@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 30, 2020
@mrboring
Copy link

mrboring commented Apr 1, 2020

@TylerLeonhardt I've done a brief test with v2020.3.2-preview. In this test intellisense was back to full speed! However, I would not be able to use this version full-time due to the dependency on Pester v5-beta. The ability to run single tests is excellent. Unfortunately it's not yet stable enough, and I'm getting tests which fail, that don't fail with Pester 4.10.1. Also, what looks like debug output. I'll create an issue in the Pester repository.

I'll try to do a longer test. After which I'ill need to revert to v2020.3.0 with it's slow intellisense, but working Pester (I unit test most code). Is there a (simple) way to use Pester 4.10.1 with v2020.3.2-preview?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 1, 2020
@TylerLeonhardt
Copy link
Member

@mrboring

The Pester behavior is configurable:

"powershell.pester.enableLegacyCodeLens": true

If youre having trouble with Pester after that setting can you open a new issue?

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 1, 2020
@mrboring
Copy link

mrboring commented Apr 2, 2020

@TylerLeonhardt I've created a new issue:
[Preview-2020.3.2] Enable Legacy Code Lens not working

Also, it looks like I will be able use 2020.3.2 and just ignore the warning. Won't know until I give it a go. Tried on another project and it wouldn't run the Pester tests. It just gave the warning:

Importing Pester module...
WARNING: Failed to import Pester version 5.0.0. You must install Pester module to run or 
debug Pester tests.       
WARNING: You can install Pester by executing: Install-Module Pester -MinimumVersion 5.0.0 
-Scope CurrentUser -Force

UPDATE: The tests will run if I manually import Pester (4.10.1) first.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 2, 2020
@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 2, 2020
@mrboring
Copy link

mrboring commented Apr 5, 2020

@TylerLeonhardt I've done a longer test with v2020.3.2 and can confirm that auto-complete performance is OK. However, it does stop working completely after some time (less than 30 minutes of coding in a project with ten small files). This was the originally reported issue @rkeithhill. It happened three times in testing today. Here are the logs for two of them:

Auto-complete stops working logs.zip

### VSCode version: 1.43.2 0ba0ca52957102ca3527cf479571617f0de6ed50 x64

### VSCode extensions:
alefragnani.Bookmarks@11.0.0
eamodio.gitlens@10.2.1
mohsen1.prettify-json@0.0.3
ms-dotnettools.csharp@1.21.16
ms-vscode.powershell-preview@2020.3.2


### PSES version: 2.1.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 5, 2020
@rkeithhill rkeithhill reopened this Apr 5, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 7, 2020
@TylerLeonhardt
Copy link
Member

I have a PR out to improve performance even more: PowerShell/PowerShellEditorServices#1251

If you would like to give it a go, I'd love the feedback.

Download this zip:
psvsix.zip

Extract it and run:

code --install-extension ./path/to/PowerShell-insiders.vsix

Make sure the regular PowerShell (stable) extension is disabled.

Restart VS Code.

To verify you've done it correctly, your version number in the extension pane for PowerShell Preview should be: 2020.4.0-CI.49654.

NOTE: This is an unsigned build and isn't supported. If you can only run signed things, don't bother trying this.

@mrboring
Copy link

mrboring commented Apr 8, 2020

@TylerLeonhardt I've spend about 90 minutes typing functions (for testing I just duplicated existing functions into a dummy project) and auto-complete has worked perfectly so far. Good performance, with no crashes.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 8, 2020
@TylerLeonhardt
Copy link
Member

Nice! At the very least it is an improvement. I'll try to push a PowerShell Preview release today or tomorrow with a Stable release next week.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 8, 2020
@stevenebutler
Copy link

I was too busy with urgent work yesterday to try this out, but I've installed it this morning and will see how it goes. Ironically if it works it would have saved me plenty of time with restarts yesterday and today I don't have the same need to do any mad scripting (yet).

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 8, 2020
@stevenebutler
Copy link

This version is significantly better than before and have not needed to restart in the last 60+ minutes, which was unheard of with the current preview. I've been reworking the script I did yesterday which it would freeze on pretty regularly so things have definitely improved.

@TylerLeonhardt
Copy link
Member

Awesome - this will be live in......... about 10 or so minutes as the PowerShell Preview extension and then if it goes well, Stable will follow next week.

@TylerLeonhardt
Copy link
Member

I will close this as we close issues when the fix is merged in and this has been merged in.

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