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

IntelliSense is occasionally slow when editing PowerShell scripts #647

Closed
tibmeister opened this issue Apr 4, 2017 · 23 comments
Closed

Comments

@tibmeister
Copy link

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

@daviwil
Copy link
Contributor

daviwil commented Apr 4, 2017

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

@daviwil daviwil added this to the Next Patch Update milestone Apr 4, 2017
@daviwil
Copy link
Contributor

daviwil commented Apr 5, 2017

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

@tibmeister
Copy link
Author

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.

@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

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.

@daviwil daviwil changed the title Intellisense is slow in PowerShell scripts Intellisense is occasionally slow when editing PowerShell scripts Apr 6, 2017
@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

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

OneGet/oneget#275

@dotps1
Copy link

dotps1 commented Apr 6, 2017

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

@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

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

@daviwil daviwil modified the milestones: Next Patch Update, Next Feature Update Apr 6, 2017
@tibmeister
Copy link
Author

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.

@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

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.

@tibmeister
Copy link
Author

Makes sense, I will keep an eye out.

daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Apr 7, 2017
This change mitigates seemingly intermittent IntelliSense slowness by
preventing Get-Command and Get-Help from being called on cmdlets from
the PowerShellGet and PackageManagement modules.  Something in the
PackageManagement module is causing completions to be returned at 10x
delay when that module is loaded.  If the module is removed from the
session, completions go back to their normal duration.

By avoiding calling Get-Command on these cmdlets, we avoid loading
PackageManagement when the user types a string like `Get-P` which
incidentally happens to make VS Code see the `Get-Package` cmdlet and
try to resolve its details.

This fix is temporary and will be removed in the future once
OneGet/oneget#275 is fixed.

Related to PowerShell/vscode-powershell#647
@daviwil daviwil changed the title Intellisense is occasionally slow when editing PowerShell scripts IntelliSense is occasionally slow when editing PowerShell scripts Apr 7, 2017
@daviwil daviwil modified the milestones: April 2017, May 2017 May 8, 2017
@daviwil daviwil modified the milestones: May 2017, June 2017 Jun 1, 2017
@v2kiran
Copy link

v2kiran commented Jun 10, 2017

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

`

@daviwil daviwil removed this from the June 2017 milestone Jul 11, 2017
@mlalkaka
Copy link

mlalkaka commented Aug 2, 2017

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

@daviwil
Copy link
Contributor

daviwil commented Aug 14, 2017

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

@daviwil daviwil modified the milestones: July 2017, Future Oct 26, 2017
@veepee78
Copy link

veepee78 commented Dec 4, 2017

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

@GHRoss
Copy link

GHRoss commented Jan 25, 2018

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

@TylerLeonhardt TylerLeonhardt modified the milestone: Future May 24, 2018
@Fontenot-Tech
Copy link

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.

@aglasson
Copy link

aglasson commented Feb 28, 2019

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.

@pluggy
Copy link

pluggy commented May 25, 2019

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 
{
    
}

}
`

@SydneyhSmith SydneyhSmith added Issue-Performance Something's slow. Triage and removed Issue-Bug A bug to squash. Triage labels May 28, 2019
@smartpcr
Copy link

smartpcr commented Nov 8, 2019

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 8, 2019
@rjmholt
Copy link
Collaborator

rjmholt commented Nov 8, 2019

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

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Nov 19, 2019
@Hypernut
Copy link

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

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

rjmholt commented Dec 15, 2019

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 #1256 (comment)

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

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

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