Why does copying files slow down?
Hi, everyone. Leo Notenboom here for
Askleo.com. Hey, if you're not subscribed
to my weekly, Confident Computing newsletter, head out to
Askleo.com/newsletter and sign up today.
I give you tips, answer questions, and more like this one.
Here's the question.
I'm experiencing a bogged-down slash hang-up when copying large files.
The PC will have to be restarted to clear this.
Any idea what could cause this annoying problem?
Yeah, these kinds of problems are really
difficult to diagnose, especially not being in front of the machine.
But I will offer you a list of things
that might explain the behavior that you're seeing, some of which might be
normal, some of which might indicate perhaps a pending problem.
The number one thing that I see, because I experience this myself not
infrequently as I copy around large files, including the video file that would
represent this video, are buffers and caches.
So what normally happens when you think
of happening when you copy a file, say, from one hard disk to another,
is that the data is read from one hard disk and written to the other
and that you're limited by the speed of one or both of the hard disks.
What typically happens instead is
that Windows will actually set aside a buffer in RAM.
Ram is much faster than hard disks,
and what it will do is it will read from that file into the buffer very,
very quickly, and then write from that buffer to the destination disk.
What this allows for is for very small
files, small-ish files, anything that's smaller than the buffer.
And honestly,
we don't know what the buffer size is, but whatever smaller than that buffer size
will appear to be copied very, very quickly because they'll fill
the buffer, the read will be done, and the write will just happen
in the background while you're doing other things.
The scenario that I encounter,
because again, we're copying very large files, is that the buffer will fill up.
And now, we're back to being limited by the speed of the hard disks.
The read will happen, of course, but then all of a sudden, the buffer will fill up.
The buffer will be emptied by the process of writing that data to the destination
hard disk, but that'll be limited by the speed of that hard disk.
So basically, the buffer will be in the middle,
but will still be limited by the speed of the hard disks.
That manifests as a really, really fast copy that then slows down
because you've reached the size of that buffer.
This can also happen without Windows being involved at all.
Many hard disks, many destination hard disks that you're writing to will
also include some buffer or cache in their electronics,
in the actual disk controller, has exactly the same manifestation.
The copy will go very,
very quickly for small files or to a point at which point things will slow down
because once again, it'll be gated by the speed of the hard
disk and not how quickly it can throw things into RAM.
Another scenario that can cause this are hard disk errors.
Now, I don't really mean hard errors, errors that would actually cause failures.
Particularly with magnetic media,
what can happen is an area on the hard disk may start to fail.
And as such, it may not be completely broken, but it'll have problems.
Windows or the hard disk controller will do everything it can to write
the data to that spot that might be getting marginal.
What that looks like, of course, is the disk.
It tries to write, it fails.
You never see any of this because
eventually, tries to write and it succeeds.
The problem, of course, is that all those retries,
which can be dozens or hundreds of retries, can take time.
So all of a sudden, you'll copy, copy,
copy, and then you'll come across this one bad sector on the hard disk,
this marginal sector on the hard disk, and it'll slow down.
And once it's done, there may be multiple
sectors like that, so it may be slow for a while, and then it might pick up again.
It's unclear. But the bottom line is that if there's
a marginal sector on a magnetic hard disk, yeah, that can manifest as slowing down.
You could try running CHKDSK slash R, and it might help.
But CHKDSK,
like Windows, doesn't really know what's going on in the hard disk inside.
So this try and fail, try and fail,
try and finally succeed will be happening underneath CheckDisk as well.
CHKDSK will, of course, if it actually can't write to that sector,
then yeah, at that point, it'll do something.
It'll mark the sector as bad
and potentially swap in some other sectors that are good.
But the bottom line is Check Desk may or may not help.
It doesn't hurt to run it, so go ahead and do that.
But it may or may not actually help.
Fragmentation is another issue.
What's interesting about this, though,
is that fragmentation is much, much, much less of an issue than it used to be.
In the past,
fragmentation or defragmentation didn't happen automatically.
Starting with Windows something or other, I think it was Windows 7.
Windows actually does defragment your
magnetic hard disks once a week automatically.
So you don't really have to do anything about that.
However, defragmentation may still not work if the hard disk
is close to being full, if there's not enough room
for the defragmenting tool to actually do its job.
It'll do what it can, but it'll still leave the disk fragmented.
That can manifest in performance issues.
Remember, fragmentation,
the whole point of defragmenting was to speed up your hard disk.
So it can still manifest as performance issues if the defragmenter was unable
to actually completely defragment that hard disk.
Again, this applies only to magnetic hard disks.
SSDs don't have this problem.
Another reason things can slow down is software.
It's very possible that while you're doing this copy, something else comes along
and either grabs the CPU or actually does something intense
with the same hard disk, one of the disks that you're reading or writing from.
That can cause your copy to suddenly slow
down because now the hard disk is having to do two things instead of one.
So that can manifest as a sudden slowdown.
An article I have that may help you diagnose what's going on in a situation
like this is I have constant disk activity, and I don't know why.
How can I tell what program is doing it?
That can help you analyze exactly what program is doing all of these writes
in addition to whatever the copy is you're doing.
You can also use Process Explorer to take
a look at the memory usage because that too can cause issues.
If all of a sudden your system runs low on memory while you're doing this copy,
then the system may start swapping to the paging file,
which again can slow down everything, including the copy that you're doing.
And finally, I do have to mention hardware.
Besides the disk surface, there's circuitry involved.
If it's an external disk, there are cables involved,
there are interfaces involved, USB connectors involved.
Those can all
fail or begin to fail in such a way that manifest as slowing down a copy.
Normally, when they fail, they fail hard, right?
Things just stop working.
But it's still possible that they can fail
in such a way that things just aren't working as smoothly as they should be.
That's something else to consider
when you're trying to diagnose exactly what's going on.
But hopefully, it's difficult for me
to say, Here's your problem, but hopefully, I've given you a few things
to look at and to consider as you try and diagnose this situation.
For updates, for comments,
probably for more ideas, for links and more, visit
Askleo.com/3578.
I'm Leo Notenboom, and this is Askleo.com.
Thanks for watching.