Skip to content

Optimize Get-ChildItem -Recurse -Name - #12834

Closed
Ilya (iSazonov) wants to merge 15 commits into
PowerShell:masterfrom
iSazonov:filesystemprovider-getnames
Closed

Ilya (iSazonov) wants to merge 15 commits into
PowerShell:masterfrom
iSazonov:filesystemprovider-getnames

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented May 29, 2020 •

Copy link
Copy Markdown
Collaborator

PR Summary

Addresses #9119

Intention is to improve performance without changing current behavior. Later we can more easily fix already known bugs/inconsistencies and add new features.

Performance win is up to 50%.
Allocations are dramatically reduces if filtering is used (now no allocations are for discarded paths).

  • Use new .Net Runtime path (folder/file) enumerator in PowerShell file system provider.
  • Refactor existing code to one method.
  • Add more tests (mainly for hidden file attribute)

Today the .Net API does not support:

  • Depth (tracking issue) and we use a workaround in the case.
  • ContinueOnError predicate and we use copy-pasted and bit enhanced code from .Net.

PR Context

Current implementation is a generic (common for all providers) enumerating code which is very expensive. New implementation uses new .Net API for file enumerating. The API is very fast and efficient, especially if filtering is used.

The follow intention is to use this approach later for dir -recurse too and then fix known bugs and add new features.

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label May 29, 2020
@iSazonov
Ilya (iSazonov) force-pushed the filesystemprovider-getnames branch from 5b8fae2 to d9673b0 Compare June 2, 2020 13:41
@iSazonov
Ilya (iSazonov) marked this pull request as ready for review December 17, 2020 16:01
@ghost ghost added the Review - Needed The PR is being reviewed label Dec 25, 2020
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@iSazonov
Ilya (iSazonov) force-pushed the filesystemprovider-getnames branch from 5ff026a to 149b003 Compare December 28, 2020 05:46
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@ghost ghost removed the Review - Needed The PR is being reviewed label Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants