Powershell: `Get-Service` is noticeably slower on PS7 than on WinPS5.1

Created on 11 Jun 2019  路  7Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Measure-Command { 1..100 | % { get-service sshd } }

Expected behavior

About the same time on both PS7 and WinPS 5.1

Actual behavior

WinPS5.1 took 100ms on my machine
PS7 took 532ms on same machine

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.1
PSEdition                      Core
GitCommitId                    7.0.0-preview.1
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Area-Cmdlets-Management Issue-Bug

Most helpful comment

I just came across this code, where ETS types are added to Get-Service output, and since this issue is related, I wanted to ask a few questions:

  1. Why are the ETS type names prefixed with System.Service.ServiceController and not the actual System.ServiceProcess.ServiceController type? This seems incorrect.

  2. Why are we inserting custom type names for each added NoteProperty? I've used ETS very heavily over the past 12 years, and while I've identified an extended type using one custom ETS name, or perhaps several if I have a hierarchy like a class hierarchy, I've never added one ETS type name per property added. That feels redundant and unnecessary, and I think these types should either be removed or replaced with a single ETS type name of System.ServiceProcess.ServiceController#Extended.

I know these should be logged as an additional issue or two, and I'll do that. I just want confirmation on the issues first since I don't have the background on why these were added with ETS names like this.

All 7 comments

My measure 526 vs 32

It come from #4907 where we added properties (BinPath, Description, UserName and Delayed Auto Start).

It seems the fix should be to move the properties to ETS and get its on demand only.

mine is (pwsh)32 Vs (powershell)1 ms


Name                           Value
----                           -----
PSVersion                      7.0.0-preview.1
PSEdition                      Core
GitCommitId                    7.0.0-preview.1
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0螕脟陋}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@kvprasoon I want to have your computer :-))))

@iSazonov , srry, I'll have to ask my manager... 馃槢

I just came across this code, where ETS types are added to Get-Service output, and since this issue is related, I wanted to ask a few questions:

  1. Why are the ETS type names prefixed with System.Service.ServiceController and not the actual System.ServiceProcess.ServiceController type? This seems incorrect.

  2. Why are we inserting custom type names for each added NoteProperty? I've used ETS very heavily over the past 12 years, and while I've identified an extended type using one custom ETS name, or perhaps several if I have a hierarchy like a class hierarchy, I've never added one ETS type name per property added. That feels redundant and unnecessary, and I think these types should either be removed or replaced with a single ETS type name of System.ServiceProcess.ServiceController#Extended.

I know these should be logged as an additional issue or two, and I'll do that. I just want confirmation on the issues first since I don't have the background on why these were added with ETS names like this.

Why are the ETS type names prefixed with System.Service.ServiceController and not the actual System.ServiceProcess.ServiceController type? This seems incorrect.

It is tricky bug :-) - no automatic display but direct access works.

For second, the intention was to use this in formatting system views. We could keep this if we make the properties "calculate-only-by-demand" for performance.

Was this page helpful?
0 / 5 - 0 ratings