Vscode-powershell: IntelliSense is occasionally slow when editing PowerShell scripts

Created on 4 Apr 2017  路  23Comments  路  Source: PowerShell/vscode-powershell

At times it could take up to 90 seconds for Intellisense to finally come up, sometimes I have to manually initiate (Ctrl+Space), and other times it comes up very quickly.

System Details

  • Operating system name and version: Wind 10 Enterprise x64, 8 CPU, 12GB RAM
  • VS Code version: 1.10.2
  • PowerShell extension version: v0.11.0
  • Output from $PSVersionTable:

Name Value
---- -----
PSVersion 5.0.10586.672
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.672
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Area-IntelliSense Issue-Performance

Most helpful comment

Intellisense is always slow for me, however it's rapid in the ISE.

All 23 comments

Is it slow after working in a session for a while or only at the very beginning?

Hey Jody, when you see this issue again, can you evaluate the $Error variable in your session and paste the output here?

Sorry, been a crazy couple of days. I can't seem to find a pattern as to when this happens, but I will keep a bit more attention to it.
I will look for the $Error to see if anything shows up, but I think that since it does eventually show up if I'm patient, it's more of a performance issue.

No problem! One more thing to try when you see this again, when IntelliSense becomes slow, try running these two commands in the Integrated Console and then try IntelliSense again to see if the speed improves:

Remove-Module PowerShellGet -Force
Remove-Module PackageManagement -Force

This takes those two modules out of the session. I suspect that they may be causing the IntelliSense slowness.

Linking this to an issue I created against the PackageManagement module since that is definitively the cause of this issue:

https://github.com/OneGet/oneget/issues/275

intellisense for the PowerShellGet module is slow even in the regular shell.

Yeah, that's because PowerShellGet loads PackageManagement, so loading either causes the slowdown.

So I don't have either of those modules loaded, using a custom profile. After updating to VSCode 1.11.1 and the 0.12.1 release of the plugin seems to help once intellisense starts it becomes very responsive. not sure what may have triggered that but will need to try it on a couple of my other systems.
I will update once I know more.

You wouldn't have loaded them on purpose, the PowerShell extension causes them to be loaded when you type a string that causes a PackageManagement cmdlet to show up in the IntelliSense results (Get-P for example). So even if you don't have them in your profile, they could still become loaded in your session.

Makes sense, I will keep an eye out.

i confirm this issue...currently this is the reason why i use ISE to write the code test and then paste into vscode for formatting and organization.
In my case the intellisense actually stops working completely. If i kill and re-open the session it
sometimes works but 99 times out of 100 it does not.

In fact i have seen this behaviour on a couple of systems so its not isolated to just one machine

I also ran the remove-module commands but none of the packagemgmt modules were loaded

`
6/10/2017 5:51:39 AM [VERBOSE] - Method "ResolveFilePath" at line 354 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Workspace\Workspace.cs
Resolved path: c:\Github\Public\dev\everything.ps1
6/10/2017 5:51:39 AM [ERROR] - Method "OnListenTaskCompleted" at line 391 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs
ProtocolEndpoint message loop terminated due to unhandled exception:

System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerShell.EditorServices.CodeLenses.ReferencesCodeLensProvider.<ResolveCodeLensAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.CodeLenses.CodeLensFeature.<HandleCodeLensResolveRequest>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerShell.EditorServices.CodeLenses.ReferencesCodeLensProvider.<ResolveCodeLensAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.CodeLenses.CodeLensFeature.<HandleCodeLensResolveRequest>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
   at System.Threading.Tasks.Task.Execute()<---

6/10/2017 5:51:39 AM [VERBOSE] - Method "DelayThenInvokeDiagnostics" at line 1409 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\Server\LanguageServer.cs
Analyzing script file: c:\Github\Public\dev\everything.ps1
6/10/2017 5:51:39 AM [VERBOSE] - Method "GetDiagnosticRecordsAsync" at line 388 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Analysis\AnalysisService.cs
Found 2 violations
6/10/2017 5:51:39 AM [VERBOSE] - Method "DelayThenInvokeDiagnostics" at line 1413 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\Server\LanguageServer.cs
Analysis complete.
6/10/2017 5:51:39 AM [VERBOSE] - Method "Post" at line 64 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Utility\ThreadSynchronizationContext.cs
Attempted to post message to synchronization context after it's already completed

`

Is there something I can do to help identify the cause of this issue? I believe I'm also experiencing the same problem (Code version 1.14.2). I tried removing the PowerShellGet and PackageManagement modules from the Integrated PowerShell Console, but it seems those modules weren't loaded (see error output below). Thanks.

PS> Remove-Module PowerShellGet -Force
Remove-Module : No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.
At line:1 char:1
+ Remove-Module PowerShellGet -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Remove-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_NoModulesRemoved,Microsoft.PowerShell.Commands.RemoveModuleCommand

PS> Remove-Module PackageManagement -Force
Remove-Module : No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.
At line:1 char:1
+ Remove-Module PackageManagement -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Remove-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_NoModulesRemoved,Microsoft.PowerShell.Commands.RemoveModuleCommand

@mlalkaka can you capture verbose logs and attach them to the thread?

Powershell Intellisense is occasionally really slow. Both regular and insider versions. Here is verbose logs from insiders version:
EditorServices.log
vscode-powershell.log

Intellisense is always slow for me, however it's rapid in the ISE.

I run into the same issue of slow intellisense as well. Running Powershell extension 1.7.0.

It is the single reason I switch back to ISE at times, especially when anything more than simple editing to existing code/scripts.

I always come back to VS Code though, for the Explorer pane to view/manage files and the source control (git) integration...even though I've built a few wrapper commands to push changes to my repo when I'm in the ISE. I've tried to 'get going' with Git a few times in the past, but using VS Code is what finally got me using it and eventually understanding it better.

I've started experiencing this same issue since the last version or two of VSCode. I never experienced slow intellisense with powershell before then. Mindful the VSCode version could just be coincidence.
If I can be of any assistance in experimenting and module changes etc. let me know.

I'm also having this problem, but for me it is always slow if I import a bunch of DSC modules. For instance try opening the dsc configuration that I pasted below, install the listed modules on your system and then test how long it takes to show code completion for a simple command like write-host.

On my main dev machine (Core i7-6900K, 32 GB RAM, Windows 10, SSD) it takes about 20 seconds.
On a different computer (Ryzen7-1700, 16 GB RAM, Windows 10, SSD) it is a lot better, though still not great (5 seconds)

`configuration DSCConfig{

Param(
[System.Management.Automation.PSCredential]$StorageBoxCredential,
[System.Management.Automation.SwitchParameter]$BootstrappingServer,
[System.Management.Automation.PSCredential]$FinalAdminPassword
)

Set-StrictMode -Version 3.0

Import-DscResource -ModuleName  PSDesiredStateConfiguration,cFirewall,xRemoteDesktopAdmin,NetworkingDsc,ComputerManagementDsc,xWindowsUpdate,PolicyFileEditor,xHyper-V,xComputerManagement,AccessControlDsc
node $AllNodes.NodeName 
{

}

}
`

Believe slowness was caused by integrated console(terminal), kill the terminal recovers it

after typing a few words, pwsh is busy (reaches 100% in mac), then have to wait a few min!! really inconvenient.

@smartpcr are you using the stable or preview extension? If on stable, maybe try the preview; powershell-preview in VSCode marketplace.

Same here.

| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.17134 |
| VSCode | 1.41.0|
| PowerShell Extension Version | 2019.11.0 |

PowerShell Information

|Name|Value|
|---|---|
|PSVersion|5.1.17134.858|
|PSEdition|Desktop|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.17134.858|
|BuildVersion|10.0.17134.858|
|CLRVersion|4.0.30319.42000|
|WSManStackVersion|3.0|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|

If you're using the stable extension, it's worth giving the preview a try, since we've been investing in performance improvements there. If you're using the preview, please let us know.

Also see https://github.com/PowerShell/vscode-powershell/issues/1256#issuecomment-565781978

Closing, if you have issues with the latest build please add your comment to #2522

Was this page helpful?
0 / 5 - 0 ratings