What is the Robocopy algorithm?

I am curious to know what makes Robocopy (Robust File Copy) so fast and reliable. Does any body know what the API / Algo used for Robocopy is? Has anyone studied Robocopy?

I ask, since I need to write a method (in .NET / C #) that will copy directories / files quickly and without errors ... The data volume can increase to 15 GB, and I can’t just call Robocopy for various reasons.

Thanks!

+4
source share
1 answer

You can get close to Robocopy speed with a simple C # program that does asynchronous reads and writes using the standard FileStream with a 64 KB buffer. Large buffer sizes up to 256 KB will give a slight increase in performance. The larger 256K, the slower they will slow down. In my tests, using a 512K buffer took almost twice as much time as copying with a 256K buffer.

The idea is pretty simple:

 Read the first buffer from the source file do { start asynchronous write to destination file. Read the next buffer from the source file wait for asynchronous write to complete } while not end of file 

This is a pretty simple thing to write. My program, which does this almost as fast as Robocopy, and does not cause the types of problems that Robocopy causes when you copy a very large (one hundred gigabytes) from the server.

A bit more information about the problem with a large copy of the files.

Please note that this asynchronous read / write function does not greatly affect performance if you read and write to the same physical disk. This is most effective when the source and destination are on different drives.

+12
source

All Articles