Powershell: Leverage multiple threads for file system provider deletes

Created on 26 Feb 2020  路  2Comments  路  Source: PowerShell/PowerShell

Summary of the new feature/enhancement

Deleting a folder that contains many items or a deep hierarchy can take a long time. Currently, PowerShell results in using a .NET API call to remove the top level folder which internally, probably calls a Win32 API (on Windows, of course) to delete that folder which serially handles it. There is an OSS tool byenow which scans the folder/file hierarchy and leverages multiple threads which results in a significant perf gain (for large folders) and even more so for remote deletes. It seems we can use a similar strategy in the FileSystemProvider when there is a recursive delete on a folder.

Issue-Enhancement WG-Engine-Providers

Most helpful comment

Wouldn't it advantageous to enhance Copy-Item -Recurse in a similar fashion? Obviously the searching and thread pooling approaches differ (top-down versus bottom-up), but they are in the same ballpark.

All 2 comments

Wouldn't it advantageous to enhance Copy-Item -Recurse in a similar fashion? Obviously the searching and thread pooling approaches differ (top-down versus bottom-up), but they are in the same ballpark.

We do manual enumerating with PowerShell magics.
We need to add more tests before changing something.

Was this page helpful?
0 / 5 - 0 ratings