-
Notifications
You must be signed in to change notification settings - Fork 8.1k
PSOptimizedProvider objects - Experimental feature #8995
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
Conversation
17ed0b3 to
1fc03a1
Compare
|
Not sure why that test fails. It passes locally 🤔 |
src/Microsoft.PowerShell.Commands.Management/commands/management/ContentCommandBase.cs
Outdated
Show resolved
Hide resolved
b6dd06d to
073cbc5
Compare
It still fail. I don't see why - need to debug. |
|
@iSazonov That seems like a genuine bug from my side. And windows only is easy to debug for me. |
|
Perhaps I don't understand you comment but the test failed on Windows Update: previous test seems works so only WhatIf parameter doesn't work. |
|
@iSazonov, @daxian-dbw Do you know how to test global experimental features? In this case, I would like to run all test with the feature both enabled and disabled, to make sure I didn't break anything in the old behavior, and that is works with the optimizations. I know about the flags to To you have any ideas on how to handle this? |
|
There is TestMetadata.json file. |
|
@powercode Here is the
Sorry that I didn't update the testing doc with this. Will do that soon. |
528df8d to
9eecd8b
Compare
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
|
Keeping this alive. Will get back to it after PSConfEU |
64cf96d to
5943ad2
Compare
|
@powercode, your last commit had 2 failures in Expected $null, but got C.
at <ScriptBlock>, D:\a\1\s\test\powershell\Modules\Microsoft.PowerShell.Management\Get-ItemProperty.Tests.ps1: line 36
36: $output.PSDrive | Should -Be $testproviderString cmdlets.Select-String.Network path Expected 2, but got 0.
at <ScriptBlock>, D:\a\1\s\test\powershell\Modules\Microsoft.PowerShell.Utility\string.tests.ps1: line 56
56: (select-string -LiteralPath $fileNameAsNetworkPath "b").count | Should -Be 2 |
|
@powercode, your last commit had 4 failures in Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/vsts/agent/2.152.1/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: /foo: Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/vsts/agent/2.152.1/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: :bar Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/vsts/agent/2.152.1/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Get-ItemProperty.Should be able to access a property using the Path and name switches Expected $null, but got /.
at <ScriptBlock>, /Users/vsts/agent/2.152.1/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ItemProperty.Tests.ps1: line 36
36: $output.PSDrive | Should -Be $testprovider |
|
@powercode, your last commit had 4 failures in Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: /foo: Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: :bar Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Get-ItemProperty.Should be able to access a property using the Path and name switches Expected $null, but got /.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ItemProperty.Tests.ps1: line 36
36: $output.PSDrive | Should -Be $testprovider |
5943ad2 to
b0b85a0
Compare
| internal sealed class FileSystem_Format_Ps1Xml | ||
| { | ||
| internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@powercode, your last commit had 4 failures in PowerShell-CI-macos
Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: \foo:bar.txt
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: /foo:
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: :bar
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Get-ItemProperty.Should be able to access a property using the Path and name switches
Expected $null, but got /.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ItemProperty.Tests.ps1: line 36
36: $output.PSDrive | Should -Be $testprovider| internal sealed class FileSystem_Format_Ps1Xml | ||
| { | ||
| internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@powercode, your last commit had 3 failures in PowerShell-CI-linux
Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: \foo:bar.txt
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: /foo:
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: :bar
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"| internal sealed class FileSystem_Format_Ps1Xml | ||
| { | ||
| internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@powercode, your last commit had 2 failures in PowerShell-CI-windows
Get-ItemProperty.Should be able to access a property using the Path and name switches
Expected $null, but got C.
at <ScriptBlock>, D:\a\1\s\test\powershell\Modules\Microsoft.PowerShell.Management\Get-ItemProperty.Tests.ps1: line 36
36: $output.PSDrive | Should -Be $testproviderString cmdlets.Select-String.Network path
Expected 2, but got 0.
at <ScriptBlock>, D:\a\1\s\test\powershell\Modules\Microsoft.PowerShell.Utility\string.tests.ps1: line 56
56: (select-string -LiteralPath $fileNameAsNetworkPath "b").count | Should -Be 2| internal sealed class FileSystem_Format_Ps1Xml | ||
| { | ||
| internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@powercode, your last commit had 3 failures in PowerShell-CI-macos
Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: \foo:bar.txt
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: /foo:
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: :bar
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /Users/runner/runners/2.160.0/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"| internal sealed class FileSystem_Format_Ps1Xml | ||
| { | ||
| internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@powercode, your last commit had 3 failures in PowerShell-CI-linux
Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: \foo:bar.txt
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: /foo:
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"Basic FileSystem Provider Tests.Validate basic FileSystem Cmdlets.Get-Content on Unix succeeds with folder and file with colon: :bar
Expected exactly 'Hello', but got $null.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1: line 246
246: $files[0] | Get-Content | Should -BeExactly "Hello"|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
PR Summary
Adds support for deriving from PSObject to create optimized CodeProperties, and uses this to implement the attached properties for FileSystem/Registry-Provider and the output of Get-Content.
This makes the FileSystemProvider roughly twice as fast getting items, and about 5 times faster getting content.
Memory usage of getting all item under c:\windows is 415Mb before the change, and 103Mb after.
To try it out:
Enable-ExperimentalFeature PSOptimizedProviderPR Context
PSNoteProperties are quite expensive. To provide core scenarios with a more performant alternative, this PR adds types derived from PSObject that are tailored for common scenarios in the providers.
The providers add six PSNoteProperties to each item, adding massively to the memory usage, and substantially to the time it takes to create the PSObjects wrapping the items.
The same thing happens with
Get-Contentwhere the attached properties can inflate the PSObjects many times over.The gist of the change is the addition of an interface,
IPSObjectExtendedMemberInfoand an attribute,PSExtensionMemberAttribute, that the derived PSObjects can use to communicate with the ETS about what members to expose.CoreAdapter has a new member,
AddExtensionPropertiesthat adds members with the attribute, and the interface provides a memberthat can be used to quickly determine if an object provides a property matching the predicate.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.[feature]to your commit messages if the change is significant or affects feature tests