Repository navigation
Add experimental lazy metadata for FileSystem provider output - #28284
Open
Staffan Gustafsson (powercode) wants to merge 4 commits into
Open
Staffan Gustafsson (powercode) wants to merge 4 commits into
Staffan Gustafsson (powercode) wants to merge 4 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Staffan Gustafsson (powercode)
force-pushed
the
Perf/FileInfoPsProps
branch
from
October 29, 2026 17:25
87346cc to
a349e6f
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved wrapper-unwrapping regressions break .NET argument handling, property assignments, and Boolean binding, while an incorrect path causes the new filesystem test to fail on Unix.
7 open issues
Unwrap PSObject subclasses for object arguments and setters · New Add a directory separator to the Unix test path · New Fix the launch task name and executable path · New Remove or update the workstation-specific WSL launch profile · New Resolve helper paths relative to the script checkout · New Unwrap wrapped byte values during Boolean parameter conversion · New Replace the hard-coded obsolete debug executable path · New
What changed in this PR
Adds the opt-in PSOptimizedProviderObjects feature to reduce provider-output allocations by deferring note-property creation until member inspection or mutation requires it.
Changes:
- Introduces inline metadata and lazy property access for FileSystem items and scalar
Get-Contentoutput. - Adds regression coverage, isolated performance benchmarks, and engine design documentation.
- Updates debugger configuration, solution mappings, and small provider/console-host details.
| File | Description |
|---|---|
TestDir/test.ps1 |
Adds a local FileSystem test helper. |
test/xUnit/csharp/test_PSObject.cs |
Tests lazy access, promotion, identity, copying, serialization, and allocations. |
test/powershell/Modules/Microsoft.PowerShell.Management/OptimizedProviderObjects.Tests.ps1 |
Adds feature-dependent provider and content integration tests. |
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 |
Updates Unix colon-path tests. |
test/perf/benchmarks/README.md |
Documents benchmark usage and measurement interpretation. |
test/perf/benchmarks/ProviderMetadata.ProcessBenchmark.ps1 |
Runs isolated baseline/candidate comparisons and generates reports. |
test/perf/benchmarks/assets/ProviderMetadata.Measure.ps1 |
Measures item/content scenarios, allocations, and retained memory. |
src/System.Management.Automation/System.Management.Automation.csproj |
Defaults UseResharper to false. |
src/System.Management.Automation/Properties/launchSettings.json |
Adds an executable debugger profile. |
src/System.Management.Automation/namespaces/RegistryProvider.cs |
Simplifies default-drive initialization. |
src/System.Management.Automation/namespaces/ProviderBase.cs |
Gates lazy FileSystem metadata attachment and preserves fallback handling. |
src/System.Management.Automation/namespaces/FileSystemProvider.cs |
Adds lexical metadata path helpers and shares path-fix logic. |
src/System.Management.Automation/engine/runtime/Binding/Binders.cs |
Separates instance-member presence checks from lazy value reads. |
src/System.Management.Automation/engine/ProviderPSObject.cs |
Implements typed metadata wrappers, compiled accessors, and FileSystem metadata. |
src/System.Management.Automation/engine/parser/Compiler.cs |
Caches reflection references for new binder helpers. |
src/System.Management.Automation/engine/MshObject.cs |
Adds provider-source attachment and lookup helpers. |
src/System.Management.Automation/engine/MshMemberInfo.cs |
Supports lazy storage and promotion to ordinary note properties. |
src/System.Management.Automation/engine/InternalCommands.cs |
Keeps exact provider-property reads lazy in ForEach-Object. |
src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs |
Registers PSOptimizedProviderObjects. |
src/System.Management.Automation/engine/CommandParameter.cs |
Expands command-parameter debugger display. |
src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs |
Avoids redundant console-mode changes. |
src/Microsoft.PowerShell.Commands.Management/commands/management/ContentOutputMetadata.cs |
Defines shared content-path accessors and per-output ReadCount. |
src/Microsoft.PowerShell.Commands.Management/commands/management/ContentCommandBase.cs |
Emits optimized scalar content and centralizes path caching. |
PowerShell.sln |
Maps Linux and CodeCoverage configurations to Release for affected projects. |
docs/building/provider-instance-metadata.md |
Explains metadata design, lifecycle, compatibility, and validation. |
docs/building/internals.md |
Summarizes the feature and links its design guide. |
.vscode/launch.json |
Adds console and WSL debugger configurations. |
Review effort: Balanced
Staffan Gustafsson (powercode)
force-pushed
the
Perf/FileInfoPsProps
branch
from
November 2, 2026 22:02
949596a to
2577db9
Compare
Use inline ReadCount and shared source context for filesystem string and scalar-byte output. Preserve legacy metadata for raw byte arrays and batches. Include regression coverage, isolated benchmarks, and engine design documentation.
Staffan Gustafsson (powercode)
force-pushed
the
Perf/FileInfoPsProps
branch
from
November 2, 2026 22:55
2577db9 to
d1f7c77
Compare
Staffan Gustafsson (powercode)
marked this pull request as ready for review
November 3, 2026 00:00
Staffan Gustafsson (powercode)
requested review from
a team,
Patrick Meinecke (SeeminglyScience) and
Dongbo Wang (daxian-dbw)
as code owners
November 3, 2026 00:00
Collaborator
Author
|
The 4 failing checks seem to be infrastructure issues. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


PR Summary
Add
PSOptimizedProviderObjects, an experimental feature that avoids allocating provider note properties until they are needed.FileSystem items and scalar
Get-Contentstrings/bytes store metadata inline inPSObject<TMetadata>. Property reads use compiled getters; member inspection or mutation materializes ordinaryPSNotePropertyobjects. Content outputs share cached paths and keep their ownReadCount. Batches, byte arrays, and other providers use the existing path.One behavior change: lazy FileSystem path properties follow the underlying object's current path after a move. Once materialized, they become snapshots. Drive/provider context, Unix stat, and content paths retain their captured values.
Performance
Measures of
Get-ChildItem | ...for different scenarios with different usage of the PS* provider properties.Master is 100% (dashed line); lower is better. Left: elapsed time. Right: allocated bytes per item.
PSPathread per item: 52.3% less time, 58.2% fewer allocated bytes.Select-Object *show little improvement.Measured on an i9-13900K with fast disks. Your mileage may vary.
Tests and docs
Adds xUnit and Pester coverage for lazy reads, mutation, binding, copying, serialization, object lifetime, content metadata, and feature-on/off behavior. Includes a process-isolated benchmark harness and an engine design guide at
docs/building/provider-instance-metadata.md.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header