Skip to content

Get-ChildItem 3x: Replace NoteProperties on FileSystem- and RegistryProvider by class backed CodeProperties. #7501

Closed

Description

When using Get-ChildItem, the ProviderBase adds these note properties:

PSChildName
PSDrive
PSIsContainer
PSParentPath
PSPath
PSProvider

This is quite expensive, both in terms of memory and execution time.

By replacing the noteproperties with a classes that lazily can compute most of the values, we can save both storage and time.

Timing:

Command 6.1-preview After change Speedup
GCI -rec -for d:\source\powershell 0.446 0.144 3.1 x
GCI -rec -for c:\windows -ea:0 12.24 6.05 2 x
GCI -rec hkcu:\ -ea:0 7.86 2.99 2.6 x

Cred to Jason Shirk (@lzybkr) - this was his idea, not mine.

Activity

  1. powercode commented on Aug 11, 2018

    @powercode
    CollaboratorAuthor

    Memory:

    image

    The yellow is after the change.
    This was measured before and after running

    Get-ChildItem -Recurse -Force d:\source\powershell

    A quite substantial memory reduction.

  2. powercode commented on Aug 11, 2018

    @powercode
    CollaboratorAuthor

    One thing to consider is if it is OK to add CodeProperties to System.IO.FileInfo and System.IO.DirectoryInfo.

  3. Jaykul commented on Aug 12, 2018

    @Jaykul
    Contributor

    The classes in question (e.g. system.io.fileinfo) are sealed, meaning you can't just inherit from them... so what did you test? (Nevermind, I looked at the PR).

    So you can definitely add properties in the TypeData as CodeProperty (resulting in a lazy load, but still C# evaluation) instead of adding them as pre-calculated NoteProperty ... There is no question of whether that's "ok" (To implement the property as a static on a helper class). I'd say, if TypeData properties work for output from provider cmdlets, then it makes sense to me to do it that way!

    I think to get the full picture of perf. you'd need to test it piping through other commands, since so many of them use the PSPath property, for instance get-childitem | get-item ... or something.

  4. powercode commented on Aug 13, 2018

    @powercode
    CollaboratorAuthor

    Joel Bennett (@Jaykul) I was more thinking about the use case when you instantiate the FileInfo by newing it up. Then it will not have the backing property object, and these CodeProperties will still be there, but empty.

    That is a change from before, when these properties was not there at all, since they are added per instance by the provider.

  5. added
    WG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance
    WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
    on Aug 13, 2018
  6. iSazonov commented on Aug 13, 2018

    @iSazonov
    Collaborator

    Should we ask PowerShell Committee? /cc Steve Lee (@SteveL-MSFT) Dongbo Wang (@daxian-dbw)

  7. changed the title [-]Replace NoteProperties on FileSystem- and RegistryProvider by class backed CodeProperties.[/-] [+]Get-ChildItem 3x: Replace NoteProperties on FileSystem- and RegistryProvider by class backed CodeProperties.[/+] on Aug 13, 2018
  8. Jaykul commented on Aug 14, 2018

    @Jaykul
    Contributor

    Staffan Gustafsson (@powercode) I would still say that I can't imagine how adding those properties through ETS could cause a problem. 😁

  9. SteveL-MSFT commented on Sep 19, 2018

    @SteveL-MSFT
    Member

    @PowerShell/powershell-committee reviewed this. Would suggest putting this feature behind an experimental flag to determine if this breaks any customers.

  10. added
    Committee-ReviewedPS-Committee has reviewed this and made a decision
    and removed
    Review - CommitteeThe PR/Issue needs a review from the PowerShell Committee
    on Sep 19, 2018
  11. powercode commented on Sep 20, 2018

    @powercode
    CollaboratorAuthor

    I completely agree. This is kind of an experiment right now - I'm also looking at derived PSObject types and changing the binders. That seems to have more potential performance wise. Both should probably be behind an experimental flag.

  12. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  13. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  14. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  15. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerBreaking-Changebreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionResolution-No ActivityIssue has had no activity for 6 months or moreWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performanceWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions