File Copy Performance to USB Drive Oscillating Between Fast and Slow
I just had the “pleasure” of having to copy the contents of a terabyte USB disk to another similar USB drive. At first, I did not give this simple task much thought. I plugged the USB cables in and made my faithful Total Commander do the work. It did not take me long, though, to notice a strange phenomenon: the copy speed would oscillate between 8 and 24 MB/s.
For 10-20 seconds it would copy quickly at around 24 MB/s, only to drop to around 8 MB/s for a while. Then it would be fast again. And slow. You get the picture. Things like this make me really unhappy…
Who’s the Bad Guy?
My first suspect was the virus scanner. I deactivated it, checked Total Commander’s copy speed indicator, and found … no change. Too bad. It is disappointing to realize your enemy is not always the culprit.
Then I played around with the power settings. The system was on the “balanced” power plan, which allows the OS to reduce the CPU frequency and do other things to reduce energy consumption. As you may have guessed, messing with the power plan did not change a thing.
Finally, after googling around fruitlessly, I checked the external hard disks’ properties in device manager. Interestingly, the write cache was disabled. This is on the “Policies” tab, where I changed the setting from “Optimize for quick removal” to “Optimize for performance”. A reboot later the oscillations were gone. With the write cache enabled, the transfer rate settled at about 16 MB/s.
What can we learn from this? Obviously, Windows disables the write cache for external hard drives in order to reduce the impact of users unplugging their disks without notifying the OS first by clicking on the “Safely Remove Hardware” icon. While it is easy to mark this as another stupid idea from Redmond (after all, performance is king to many of us), I find it more interesting to ask whether copy performance is affected at all. A write cache can speed up writes significantly, but only if a substantial amount of the data to be written fits into the cache. As soon as the cache is filled, the transfer rate is reduced to the actual write performance of the disk again (in this case: to the rate the USB chip in the drive enclosure can cope with). So when looking at a large copy job, the write cache mainly levels the transfer rate curve. That conveys the impression of a nice steady transfer, but it does not change the overall transfer rate. This conclusion is consistent with my empirical findings – turning the write cache on did not substantially change the overall time for the copy job to complete.
I made my observations on Windows 7 RC. They may or may not apply to other versions of Windows.
Another small thing I learned: you do not want your system to go to sleep in the middle of the copy job. This can easily prevented by activating presentation mode: press Win+X to switch it on.