Slow Large File Copy Issues

Published 08 May 07 06:38 AM

From time to time, customers will call in to report "performance problems" that they are having when copying large files from one location to another.  By "performance problems", they mean that the file isn't copying as fast as they expect.  The most common scenario is copying large SQL databases from server to server, but this could just as easily occur with other file types.  More often than not, the customer has tried different methods of copying the file including Windows Explorer, Copy, XCopy & Robocopy - with the same results.  So ... what's going on here?

Assuming that you aren't experiencing network issues (and for the purposes of this article, we'll assume a healthy network), the problem lies in the way in which the copy is performed - specifically Buffered v Unbuffered Input/Output (I/O).  So let's quickly define these terms.  Buffered I/O describes the process by which the file system will buffer reads and writes to and from the disk in the file system cache.  Buffered I/O is intended to speed up future reads and writes to the same file but it has an associated overhead cost.  It is effective for speeding up access to files that may change periodically or get accessed frequently.  There are two buffered I/O functions commonly used in Windows Applications such as Explorer, Copy, Robocopy or XCopy:

  • CopyFile() - Copies an existing file to a new file
  • CopyFileEx() - This also copies an existing file to a new file, but it can also call a specified callback function each time a portion of the copy operation is completed, thus notifying the application of its progress via the callback function.  Additionally, CopyFileEx can be canceled during the copy operation.

So looking at the definition of buffered I/O above, we can see where the perceived performance problems lie - in the file system cache overhead.  Unbuffered I/O (or a raw file copy) is preferred when attempting to copy a large file from one location to another when we do not intend to access the source file after the copy is complete.  This will avoid the file system cache overhead and prevent the file system cache from being effectively flushed by the large file data.  Many applications accomplish this by calling CreateFile() to create an empty destination file, then using the ReadFile() and WriteFile() functions to transfer the data.

  • CreateFile() - The CreateFile function creates or opens a file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe. The function returns a handle that can be used to access an object.
  • ReadFile() - The ReadFile function reads data from a file, and starts at the position that the file pointer indicates. You can use this function for both synchronous and asynchronous operations.
  • WriteFile() - The WriteFile function writes data to a file at the position specified by the file pointer. This function is designed for both synchronous and asynchronous operation.

For copying files around the network that are very large, my copy utility of choice is ESEUTIL which is one of the database utilities provided with Exchange.  To get ESEUTIL working on a non-Exchange server, you just need to copy the ESEUTIL.EXE and ESE.DLL from your Exchange server to a folder on your client machine.  It's that easy.  There are x86 & x64 versions of ESEUTIL, so make sure you use the right version for your operating system.  The syntax for ESEUTIL is very simple: eseutil /y <srcfile> /d <destfile>.  Of course, since we're using command line syntax - we can use ESEUTIL in batch files or scripts.  ESEUTIL is dependent on the Visual C++ Runtime Library which is available as a redistributable package.

 - Aaron Maxwell

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# nitink said on May 8, 2007 10:09 AM:

What ROLE would IRPStackSize play in such scenarios.. I know that usually tweaking this reg value would work-around similar problems

# Carpe Diem: Flaphead.com @ Home said on May 8, 2007 1:10 PM:

This is an interesting post from the performance team blog ... bottom line, if your copying a really

# Merckury said on May 8, 2007 3:18 PM:

you can also use esefile.exe from the same place on the Exchange Server.

# Luke said on May 8, 2007 4:24 PM:

Has anybody done any testing to see how much quicker eseutil would be compared to robocopy?

# Billy Dhillon said on May 9, 2007 11:45 AM:

Great Article Aaron!

I think this is really good to point out because when you are doing large file copies using anything with Buffered I/O, you can actually exhaust your resoruces.

Buffered I/O will consume Paged Pool (1 KB of paged pool is required for each megabyte MB of file size that is opened for buffered I/O)

So the Bigger your File Copy, The more Paged Pool you will consume and eventually your Copy might fail if your resource runs out before your copy Finishes.

Thats why its good to use tools such as ESEUTIL that don't utilize CopyFile or CopyFileEx for large file copies.

# Rex2002 said on May 11, 2007 9:06 AM:

I test it for BKF files... 2Gb aprox.

The Copy And Paste last 3 minutes

The eseutil takes over 6 minutes :(

# Easyshizz said on May 15, 2007 2:54 PM:

I like wget the best and it's gpl'd

http://www.gnu.org/software/wget/index.html#downloading

# subject: exchange said on May 22, 2007 3:17 AM:

Every Exchange Administrator knows what ESEUTIL does. It can be used to defragment the Exchange databases

# Mauro Kirsch said on May 29, 2007 9:37 AM:

Great Article,

Remembering that the option of copy files the ESEUTIL alone is available on Exchange Server 2003, on Exchange 2000 Sever it does not have this option.

regards,

Mauro Kirsch

mkirsch@br.ibm.com

# Chris Portman said on July 2, 2007 9:03 AM:

I was able to copy a 250 gig database file in just over an hour using ESEUTIL.  The same copy took 4 hours using robocopy.  What a great tool!

# Kevin Floyd said on July 10, 2007 11:05 PM:

This does one file at a time I assume? I can't specify an entire directory, for instance an oracle directory where there are 70 or 80 database files, all roughly 2 gig per DB part.

# John W said on July 11, 2007 6:17 PM:

Kevin:

ESEUTIL does one file at a time.  Not a big problem though; just connect it to the for command.

Ex: for %f in (d:\source\directory\*.MDF) do ESEUTIL /Y "%f"

# Bryan said on July 11, 2007 7:44 PM:

Aaron:

You really really REALLY oughta suggest this to the robocopy maintainers!

$0.02 ;)

# Dave Sucsy said on July 12, 2007 11:33 PM:

This is CRAZY!!! I need to get work done. I'm a pro photographer and move large amounts of files around on internal, external (USB and 1394) and network drives. WinXP would move files on internal drives as fast as the drives could go. Vista (the albatross) cuts my file transfer speeds to between 1/4 and 1/10 XP speeds. WHY does Microsoft do this crazy stuff??? I have spent days researching and optimizing Vista to try to get it to where XP was as an out-of-the-box product, and Vista is still doing an excellent job of thwarting all of my attempts at productivity. Are you trying to get me to abandon Microsoft entirely and go Linux or Apple?

# Dave Sucsy said on July 12, 2007 11:34 PM:

This is CRAZY!!! I need to get work done. I'm a pro photographer and move large amounts of files around on internal, external (USB and 1394) and network drives. WinXP would move files on internal drives as fast as the drives could go. Vista (the albatross) cuts my file transfer speeds to between 1/4 and 1/10 XP speeds. WHY does Microsoft do this crazy stuff??? I have spent days researching and optimizing Vista to try to get it to where XP was as an out-of-the-box product, and Vista is still doing an excellent job of thwarting all of my attempts at productivity. Are you trying to get me to abandon Microsoft entirely and go Linux or Apple?

# Rob said on July 25, 2007 5:52 PM:

Holy CRAP!  I can't thank you enough for this.  I thought for a long time that my Promise SX4000 IDE RAID5 was my performance killer.  I tend to transfer large DVD ISOs.  

Using copy, I got about 5MB/sec writes over gigabit.  Server computer was essentially useless until the copy completed.

Using eseutil, I get about *40*MB/sec!    

I have been searching for the cause of this issue for DAYS and finally stumbled on your post.  I fought with the gigabit network card, and system cache tweaking, all to no avail.  

Computer is still pretty bogged down during the transfer.  The system cache jumps to 750MB (out of the system's 1GB) usage which is the probable culprit.  But now it takes less than 1/8th the time to move the data, so the whole situation is a lot more tolerable.  I eventually figured out that the problem only was with a network file copy and not a local transfer.

# Magnus Rasmussen said on August 2, 2007 3:27 PM:

Any answer from microsoft on this issue? Same in both vista x64 and vista x86. Large files. Tried 8-20GB files. Copy is fast but consumes all memory on the sending machine.

# Clyde Tilley said on August 8, 2007 4:49 PM:

I found this solution to SLOW file copy/delete/move:

Open Programs & Features

Select Turn Windows Features On or Off

De-select Remote Differential Compression

Select OK

It will take several minutes for this to be de-activated.

Reboot to be sure it takes.

Now these operations fly!

# Martin Cottingham said on September 13, 2007 4:01 AM:

I am copying 40 2Gb files every night & all other attempts have failed, so far this seems to be working great. Who says that the internet is full of rubbish.

The bottom line for Windows though is that you shouldn't have to muck about like this, it should just work. I am copying between 2 Windows Server 2003 R2 machines, this is basic stuff.

Even with this command though I am only getting 20% throughput on a 1Gb network, no other devices connected.

# Martin Cottingham said on September 13, 2007 4:53 AM:

I have now found Teracopy. Free, faster that eseutil & simple:

http://www.codesector.com/teracopy.asp

# Jack Farrel said on September 18, 2007 4:34 AM:

I had just the same issues. Every "big data" copy was very slow. I've tried a lot of different tools and stopped at secure copy. http://www.scriptlogic.com/products/securecopy/  Ultra fast copying because of multithreaded technology, stability work, friendly gui interface, retaining shares and permissions during copying - those are only a few advantages of this solution. Hope it helps.  

# Poul Erik said on October 30, 2007 5:25 AM:

Are there any guide lines for how much free space you need on System drive too copy a 100GB file from e: to F:. When I try on a system with 35 GB free space on the system drive if fails even though the copy is not to the C drive but from E to F. Any one?

# Jeff Hisson said on October 30, 2007 5:10 PM:

Yeah well I beat my head against the wall trying to copy large files(>33GB) and directory permissions....essentially trying to migrate a basic volume to another larger drive. I tried Robocopy but the files corrupted. XXCopy succedded in copying a single large file but failed on the directory permissions. Swing volume using MSBackup stalled...anybody have any additional freeware utils?

# Ivan said on November 22, 2007 11:11 AM:

Recently i tried to burn 506mb of different files to dvd... same thing. it took me cca. 20 minutes, and (IIRC) the same operation takes 3-5 minutes on xp. please hurry with the sp1 :D

# Eric Ericson said on December 5, 2007 5:57 PM:

I'm really pleased I found this little nugget. I was banging my head up against the disk buffer while trying to move a 400GB SQLServer mdf file from one disk shelf to another.

I never waited to completion on the robocopy approach, but just from the back of the napkin calculations I'm seeing so far it look like ESEUtil is about 3x the speed.

# Tom said on December 10, 2007 11:36 PM:

try this link I went from a 2.3m to 34m just with the patch on the site    http://securevista.net/

# Chris said on December 21, 2007 11:34 AM:

I have tested copying a 4 gig file using ESEUTIL, RoboCopy, command-line copy and Windows Explorer Cut and Paste.  Windows Explorer Cut and Paste was fastest.

Windows 2003 EE SP2

# Adam said on January 18, 2008 3:57 PM:

4 GB is really not that large a file. If your machine has 2GB or more of memory, a buffered I/O scenario should probably work fine. However, try copying 5 GB files at a time, while doing other operations on the computer that take up paged locked memory.

# Warren said on January 18, 2008 9:18 PM:

I just ran into a situation with Eseutil where I am trying to copy a 100gb file from a  3 disk RAID 5 array to an external eSata hard drive. The file copy gets to about 70% and then the RAID controller goes all wonky and basically disconnects from the system until the next reboot. We then need to add another drive to the array, rebuild the drive and then re-add the supposed bad hard drive back into the array. In other words,  the drives are fine; it's the controller that gives out.

I am concluding that the RAID controller that I am trying to use is buggy. I have tried another controller from the same manufacturer with the same results.

Eseutil is obviously copying the file so fast that it is triggering a bug in the controller. Eseutil has helped me identify this bug. Jury is still out as to whether this will happen when I use Robocopy or another file copy program.

The controller in question is a:

Highpoint RocketRaid 1640

Hopefully somebody finds this information useful.

# jim esposito said on February 12, 2008 11:17 AM:

Need the ESEUTIL copy to overwite the exisitng file.

Any advice???

Leave a Comment

(required) 
(optional)
(required) 

About CC Hameed

I joined Microsoft as a Support Engineer on the Performance team in September 2005. Prior to that I spent a couple of years working the late night shift on our Platforms 24x7 team. Working for Microsoft was always a dream job - so I am living the dream! I was on the Windows Vista Beta team in 2006, which was one of the coolest projects I have ever worked on, until I took on the task of driving the AskPerf Blog. As you can tell by my logo, I am a huge Manchester United fan and I have successfully managed to brainwash my two daughters into sharing my passion for the Red Devils much to the dismay of their mother! I also coach both my daughters' soccer teams. In addition I am an avid MMO gamer, and have an extensive DVD movie collection.

This Blog

Syndication

Page view tracker