-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add progress to Copy-Item
#18735
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
Add progress to Copy-Item
#18735
Conversation
Copy-Item
for local filesCopy-Item
for local files
The main community feedback appears to want to opt into progress. However, the current design pattern for PowerShell is to control this via |
This to me looks better & if we could in future on per cmdlets change progress preferences like Error action etc this would be a nicer opt out mechanism which I'll raise another issue to discuss this idea shortly |
My comment #18728 (comment) is still actual. |
I've moved the calculation of the totals to a new thread which removes the concern about impacting the start of copying. |
Copy-Item
for local filesCopy-Item
for local files
25f2452
to
62757a0
Compare
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
The @PowerShell/wg-powershell-cmdlets discussed this and agrees on the current design which is to asynchronously collect the total files/bytes information at the start of copying. However, estimating time remaining has never proven to be accurate and may raise more concerns so we recommend not including the time remaning. |
I'm good with it, and I think progress should be default, its convention to expect some commands to emit progress and some not, I can't imagine there's a lot of breaking changes where someone would be explicitly capturing the progress stream and sudden introduction of copy-item results into that stream would break their flow, it would have to be very very niche. I should note I am one of those theoretically "niche" people as the Pester VSCode extension breaks output into streams, but I just silently discard progress as its not useful so this wouldn't break me for instance. |
This change could benefit from the utils function |
@SteveL-MSFT - Re the last point I'd say that in line with other tooling this gives only an estimation and is how we'd expect it based on all the potential reasons why it may not finish as quick as we'd like, which inc CPU, network, disk, or memory contentions that are out of most users control. This at least on windows can be overriding by what priority we give the process running this task, which comes with its own set of risks but is one that allows additional flexibility going forward. Was that aspect considered? Because if not it may be good to review again. |
@bergmeister it already should benefit from it I think thou @SteveL-MSFT or others may correct me if I am wrong here |
File progress estimations are notoriously difficult to do, moreso on spinning rust than SSDs, because little files take exponentially more time per GB than big files due to the overhead of transfer setup/teardown. Estimates can be based on how many files left, how much throughput, or as advanced as "bucketing" certain file sizes into groups and taking a weighted average of the gb/sec transfer time of those files. Any way you slice it the estimate can be thrown off very easily, so while I personally don't see any harm to it, someone who doesn't understand why the estimates vary so wildly or are inaccurate may not be so forgiving. |
Copy-Item
for local filesCopy-Item
for local files
Took care of most of the feedback. |
b4bd8d5
to
6372a20
Compare
@kilasuit I believe the latest update addresses your concerns. See the updated gif. @bergmeister Updated using your humanizer code. |
Copy-Item
for local filesCopy-Item
@SteveL-MSFT I'd still like to see an estimated amount of time just like in file explorer copy or just like most other copying utilities out there. though perhaps this could be added via an additional parameter instead of being the default? |
|
As funny as that is @bergmeister I am sure Especially if you look at things like estimated download times in any other software (which is essentially the same thing, just a different way of thinking of it) The reason being is that you can by seeing that more easily work out, when you might be able to come back to that series of tasks and start the next one, which for many in interactive scenarios is what they need to be able to manage all of their many spinning plates. |
I agree that we should look to expand how non-interactive works & this should be discussed in an new issue @iSazonov do you want to raise it? |
use EnumerationOption instead of manually recursing
Co-authored-by: Ilya <darpa@yandex.ru>
Co-authored-by: Ilya <darpa@yandex.ru>
…the file name as a string and we need the size
Co-authored-by: Ilya <darpa@yandex.ru>
Co-authored-by: Dominik Kaszewski <dakaszewski@gmail.com>
Co-authored-by: Dominik Kaszewski <dakaszewski@gmail.com>
614f70e
to
3f9dd31
Compare
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
@iSazonov I would suggest we take this PR so we can get user feedback. The risk of adding additional fields (as there's already existing ones in FileSystemProvider) is minimal. You have valid concerns about non-interactive scenarios and should be discussed in a new issue. Note that if you use |
Since ProgressBar is considered unimportant and unimportant, based on previous experience I have no desire to fall into lifeless discussions and especially unanswered PRs. |
🎉 Handy links: |
PR Summary
To show useful progress, this change requires collecting total files/bytes information first. The initial collection of total files and bytes is on a separate thread so no impact to start of copying. This should address the primary concern from the community.
For the PowerShell repo (about 705 MB and > 9000 files), it took 16.5s with this change, and 15.7s without this change. This was not a scientific measurement.
Replaces #18728
There's also a small fix to progress display where 0 percent complete was showing a full bar.
PR Context
Fix #18637
Fix #18850
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).