I have a C# application and am using the FileStream class to read a 120GB file from an *EDIT * isilon storage unit (mapped to z drive) over gigabit LAN. I start by getting 45 megabytes / second read speeds, but at about the 20GB range my read speeds drop dramatically and settles to about 9 megabytes / second. Does anyone have any ideas on what might be causing the slowdown?
Server is Windows Server 2008 Enterprise R2 64 bit, 16 GB RAM, dual quad core CPU and my app is a 64 bit .NET framework 4.0 console application. Here’s my code:
byte[] buffer = new byte[16777216];
int count;
long totalBytes = 0;
FileStream file = File.OpenRead("z:\bigfile.dat");
while ((count = file.Read(buffer, 0, buffer.Length)) > 0)
{
// I track megabyte / second here
totalBytes += count;
}
Turns out I was actually reading over the network. I thought my mapped drive was local, but it was not. I still have the problem when reading over the network, but when I now actually read the file from local disk, speeds are what I expect. Thanks everyone.
EDIT I fixed the problem reading over the network. You can create a FileStream that does not use the windows cache with this code:
The 0x20000000 is a flag that does not have an enumeration in the .NET framework yet, but it basically says to not use the cache.
http://msdn.microsoft.com/en-us/library/cc644950%28v=VS.85%29.aspx