Skip to content

PSSession is very slow #1648

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

Open
MattLParker opened this issue Dec 11, 2018 · 12 comments
Open

PSSession is very slow #1648

MattLParker opened this issue Dec 11, 2018 · 12 comments

Comments

@MattLParker
Copy link

Issue Description

Issue Type: Performance Issue

When using powershell (64 or 32) for around 5-10 minutes, running run code snip or debug will result in cpu spikes on powershell, and will hang in the integrated console for multiple minutes, even on a command that runs near real time.

Attached Logs

Log will be emailed.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.17763
VSCode 1.29.1
PowerShell Extension Version 1.10.1

PowerShell Information

Name Value
PSVersion 5.1.17763.134
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.17763.134
BuildVersion 10.0.17763.134
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
bracket-pair-colorizer-2 CoenraadS 0.0.25
code-settings-sync Shan 3.2.3
eml leighlondon 0.3.1
gc-excelviewer GrapeCity 2.1.26
gitlens eamodio 9.0.3
material-icon-theme PKief 3.6.1
mssql ms-mssql 1.4.0
night-owl sdras 0.4.2
PowerShell ms-vscode 1.10.1
rainbow-csv mechatroner 0.8.0
reg ionutvmi 0.0.2
rest-client humao 0.20.4
sort-lines Tyriar 1.7.0
theme-cobalt2 wesbos 2.1.6
vscode-hasher deerawan 1.0.1
vscode-pull-request-github GitHub 0.2.3
xml DotJoshJohnson 2.3.2
@SydneyhSmith
Copy link
Collaborator

@MattLParker Thanks for submitting this issue, we are tracking this performance issue here #1464 so I will close as a duplicate.

@rjmholt
Copy link
Contributor

rjmholt commented Dec 18, 2018

It appears that when using import-pssession with a -prefix
it seems to continually hang due to the large number of new commands that it is importing.
in my test I am doing a single function that connects to two seperate exchange enviroments, both with a custom prefix. So for example I will have a get-01mailbox and get-02mailbox. It seems that it will continually try importing, then failing and repeating the process.

@MattLParker I'm going to reopen this issue to track separately.

Just FYI we've currently got quite a large backlog to get through at the moment, and a performance/deadlock issue like this is something that (1) may be fixed by other efforts to improve performance/deadlocks globally (the main thing we are trying to work through in our backlog at the moment) and (2) is very tricky to debug. With that in mind, it's unlikely we'll be able to look into this any time soon, but if you keep hitting this, any information you can provide here will be helpful.

@SeeminglyScience has encountered other bad threading behaviour and it has to do with our thread model colliding with PowerShell's own threaded behaviour in various places. So it may well be that resolving thread bugs we are looking at now will also alleviate this.

@MattLParker
Copy link
Author

It does happen every time I load the function, I will pull more info on it.

@MattLParker
Copy link
Author

MattLParker commented Dec 18, 2018

So interestingly, it looks as if when intellisense does its normal "get-help" its erroring out as it is looking up for example the remote command get-mailbox with prefix ga, as get-help get-gagamailbox. It is prefexing the prefix twice in the same command. although that is not what is in the code that it should be looking up.
Here it is trying to load the definition.
image
and the corresponding diagnostic log.
image
So after some time, it times out as error as this isn't a valid search.

@rkeithhill
Copy link
Contributor

It's gone all "gaga" on you. Doh! Hopefully that will be a simple fix.

@rjmholt
Copy link
Contributor

rjmholt commented Dec 18, 2018

So interestingly, it looks as if when intellisense does its normal "get-help" its erroring out as it is looking up for example the remote command get-mailbox with prefix ga, as get-help get-gagamailbox. It is prefexing the prefix twice in the same command. although that is not what is in the code that it should be looking up.
Here it is trying to load the definition.

@MattLParker would you be able to open a new issue for this?

@MattLParker
Copy link
Author

I mean I can but where?

@rjmholt
Copy link
Contributor

rjmholt commented Dec 18, 2018

Just in this repo. I mean that the Get-Help problem is unrelated to the other one, so it needs a different work item.

@MattLParker
Copy link
Author

The original is me for this problem. ?

@rjmholt
Copy link
Contributor

rjmholt commented Dec 18, 2018

There seem to be two orthogonal problems:

  1. Import-PSSession taking much longer in the Integrated Console than in a normal PowerShell console. That's a tricky performance/threading problem that could be very difficult to debug and we should track the work in this issue.
  2. Get-Help is trying to find help for a command that doesn't exist because somewhere the input its using was built incorrectly (Get-Help Get-gaMailbox becomes Get-Help Get-gagaMailbox). That's just a semantic error and might be a simple fix based on a string building error or similar.'

Is that accurate?

@MattLParker
Copy link
Author

I believe that all of my lag (1) is actually directly related to (2), I ran some code and through the log, found the same get-helps during the hang in execution of code.

@SeeminglyScience
Copy link
Collaborator

One thing we should consider doing is caching the result of Get-Help. It does have caching built in already, but it does not appear to cache failures which tend to take awhile.

If we don't already, we should also skip the Get-Help call if we can't find a CommandInfo for the target.

@SydneyhSmith SydneyhSmith changed the title Integrated Console Lag PSSession is very slow Aug 29, 2019
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

5 participants